-
Notifications
You must be signed in to change notification settings - Fork 775
Description
Note
QUnit 3.0 introduces an ESM distribution (qunit/esm/qunit.module.js
), alongside the existing qunit/qunit.js
file in the CJS format. Both are available for download.
Browser support for the CJS format is the same as in QUnit 2.x (including IE 9-11 and Safari 7+). If you choose to opt-in to the ESM format, note that this does not support running tests in IE 9-11 or Safari 7-9.
When testing in Node.js, we automatically select a format based on require()
vs import
. Both share the same instance internally so mixed usage is okay. If some configuration files, plugins, adapters, test runners, or test files import QUnit differently, everything still works fine.
An ESM build would be nice given that browser support for modules is mature these days.
Currently to use modules when testing with QUnit I do something like this:
<script src="https://code.jquery.com/qunit/qunit-VERSION.js"></script>
<script type="module" src="./test.js"></script>
local_qunit.js
export default window.QUnit;
test.js
import QUnit from './local_qunit.js';
Given that qunit is using rollup for the build it should be relatively straight-foward to add a second build output for use with <script type="module">
so you would be able to do:
import QUnit from 'https://code.jquery.com/qunit/qunit-VERSION.mjs';
...