- To provide a convenient API for making common assertions
- To work both for testing synchronous and asynchronous DOM features in a way that promotes clear, robust, tests
The basic usage of the harness (
testharness.js) is described in the beginning of the file.
- To use this script file, import the script into the test document via the following script tag. Note that an expectation is that all tests must be run-able in place in the W3C's test repository. As such, an absolute path to the script file must be used and the script file will be in
resourcesdirectory at the root of the repository.
- Each test can have one or more asserts. Note: some prefer a test is limited to a single assert but that is not mandatory.
- Each test is atomic in the sense that a single test has a single result (pass/fail/timeout).
- A test fails at the first failing assert, and the remainder of the test is (typically) not run.
- If the file containing the tests is a HTML file with an element of id "log", this will be populated with a table containing the test results after all the tests have run.
Bug Reporting and Discussion
The discussion forum for the test harness is the W3C's cross-WG
public-test-infra mail list. This list is also used to report
testharness.js bugs or bugs can also be directly added to the W3C's Bugzilla: Product = Testing; Component = testharness.js (James Graham is the "default assignee"). You can also do pull requests on the testharness.js repository on GitHub.
See Also ...
- For more information about this harness, see the documentation included at the top of the
testharness.jsor poke around in already existing files.
- A nice howto: Robin Berjon's using-testharness.js