Détail du package

web-test-runner-qunit

brandonaaron33ISC2.0.0

A @web/test-runner test framework adapter for QUnit.

readme

QUnit @web/test-runner

Use QUnit with the @web/test-runner.

Quick Start

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.

Gotchas and/or Limitations

Only shows the first assertion failure per test

@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 Reporting

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.

Assertions that occur after a test finished

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.

changelog

Changelog

[2.0.0] - 2024-02-18

A special thanks to @rnixx and @Krinkle for helping shape this update.

  • BREAKING: Only one failed assertion per a test is reported. This is due to being only able to map one error to an @web/test-runner TestResult.
  • Reporting of actual/expected diffs on a failed assertion.
  • Errors reported via QUnit's error event are now included as @web/test-runner TestSession.errors.
  • Updated dev dependencies

[1.0.0] - 2023-11-27

Initial release