Global

Type Definitions

testCodeCallback(objects)

This is the code for a test case. It may return a external:Promise if there is async behavior that must be waited-on to properly assert behavior.

Parameters:
Name Type Description
objects Object

objects passed into your test that you may need.

Properties
Name Type Description
window Window

Access to the top-level window object. Note that this provided by JSDOM and is not exactly like the Window you'd get in your browser.

document Document

Access to the top-level document object. Note that this provided by JSDOM and is not exactly like the Document you'd get in your browser.

assert Object

The NodeJS assert object that you should use to assert behavior.

fetchRequests Object

An array of Request instances given to fetch. This will be updated as fetch is called and can be useful to assert the contents of what was requested via fetch.

Source:
Examples
test("some test", ({document,assert}) => {
  const element = document.querySelector("div")
  assert(div.getAttribute("data-foo") != null)
})
test("some other test", ({document,window,assert}) => {
  const element = document.querySelector("div")
  assert.equal(window.history.state["foo"], "bar")
})