Use QUnit with the @web/test-runner.
Install:
npm i -D @web/test-runner qunit web-test-runner-qunit
Add the following to your web-test-runner.config.js
:
export default {
//...
nodeResolve: true, // this is required
testFramework: {
path: './node_modules/web-test-runner-qunit/dist/autorun.js',
config: {
// QUnit config (see type WTRQunitConfig)
// noglobals: true
}
}
//...
}
Check the examples/minimal folder for a complete example.
@web/test-runner has a specific data structure it wants. Each QUnit.module
maps to a TestSuiteResult
and each QUnit.test
maps to a TestResult
. The TestResult
has only one associated TestResultError
. So only the first failed assertion is passed along as the TestResultError
.
Progress isn't reported per test but instead is per a test file. This currently appears to be a limitation of this type of custom runner for @web/test-runner.
This does not capture assertions that happen after the full test suite has finished running (the runEnd
QUnit event). This could happen if there is an issue with an async test that triggers an assertion after the test suite has finished running. Perhaps a workaround could be to utilize assert.expect
.