This is an old revision of the document!
A script test is a test that uses JavaScript to programmatically verify one or more specific functionalities. Unlike self-describing tests and reftests, script tests do not verify rendering.
Script tests should be used to verify functionalities that do not require rendering, for example, a JavaScript API. Script tests can also be used to add automation to reftests for clients that do not support reftests.
A script test can be written as a single file with a script block that contains the JavaScript, or the JavaScript can be contained in a separate .js file that is imported by the test file.
The test harness (written and maintained by James Graham) is a JavaScript file that facilitates writing test cases. Specifically, test harness offers test authors:
Script tests written for the CSSWG should use test harness whenever possible.
The basic usage of the test harness (testharness.js) is described in the beginning of the file.
<script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script>
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”).
Additionally, test-specific metadata can be passed in the properties. These are used when the individual test has different metadata from that stored in the <head>. The recognized metadata properties are:
Example:
test(function() { assert_true(true); }, 'test_name',
{ help: 'http://www.w3.org/TR/spec#section',
assert: ['this tests something.', 'This also tests something else.'],
author: 'John Doe <john@doe.com>' });
These values would override any metadata set in the <head> of the test and are only needed when the individual test's metadata is different from what's in the <head>.
If there is only a single script test in a file, all metadata should be in the <head>.