Skip to content

Commit

Permalink
Demos: Add integration test for require('qunit').QUnit
Browse files Browse the repository at this point in the history
Ref #1551.
  • Loading branch information
Krinkle committed Aug 26, 2024
1 parent 112dacc commit 7d7eb09
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 11 deletions.
38 changes: 27 additions & 11 deletions demos/bundlers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ QUnit.test.each('test in Node.js [indirect]', indirectFiles, function (assert, f
{ cwd: DIR, env: { qunit_config_reporters_tap: 'true' }, encoding: 'utf8' }
);
const expected = `
1..4
# pass 4
1..5
# pass 5
# skip 0
# todo 0
# fail 0`.trim();
Expand All @@ -76,25 +76,29 @@ Testing http://localhost:8000/tmp/test-import-default.umd.html .OK
>> passed test "import-default"
Testing http://localhost:8000/tmp/test-import-default.webpack.html .OK
>> passed test "import-default"
Testing http://localhost:8000/tmp/test-import-indirect.es.html ....OK
Testing http://localhost:8000/tmp/test-import-indirect.es.html .....OK
>> passed test "import-default"
>> passed test "import-named"
>> passed test "require-default"
>> passed test "require-sub"
>> passed test "import-indirect"
Testing http://localhost:8000/tmp/test-import-indirect.iife.html ....OK
Testing http://localhost:8000/tmp/test-import-indirect.iife.html .....OK
>> passed test "import-default"
>> passed test "import-named"
>> passed test "require-default"
>> passed test "require-sub"
>> passed test "import-indirect"
Testing http://localhost:8000/tmp/test-import-indirect.umd.html ....OK
Testing http://localhost:8000/tmp/test-import-indirect.umd.html .....OK
>> passed test "import-default"
>> passed test "import-named"
>> passed test "require-default"
>> passed test "require-sub"
>> passed test "import-indirect"
Testing http://localhost:8000/tmp/test-import-indirect.webpack.html ....OK
Testing http://localhost:8000/tmp/test-import-indirect.webpack.html .....OK
>> passed test "import-default"
>> passed test "import-named"
>> passed test "require-default"
>> passed test "require-sub"
>> passed test "import-indirect"
Testing http://localhost:8000/tmp/test-import-named.es.html .OK
>> passed test "import-named"
Expand All @@ -112,27 +116,39 @@ Testing http://localhost:8000/tmp/test-require-default.umd.html .OK
>> passed test "require-default"
Testing http://localhost:8000/tmp/test-require-default.webpack.html .OK
>> passed test "require-default"
Testing http://localhost:8000/tmp/test-require-indirect.es.html ....OK
Testing http://localhost:8000/tmp/test-require-indirect.es.html .....OK
>> passed test "import-default"
>> passed test "import-named"
>> passed test "require-default"
>> passed test "require-sub"
>> passed test "require-indirect"
Testing http://localhost:8000/tmp/test-require-indirect.iife.html ....OK
Testing http://localhost:8000/tmp/test-require-indirect.iife.html .....OK
>> passed test "import-default"
>> passed test "import-named"
>> passed test "require-default"
>> passed test "require-sub"
>> passed test "require-indirect"
Testing http://localhost:8000/tmp/test-require-indirect.umd.html ....OK
Testing http://localhost:8000/tmp/test-require-indirect.umd.html .....OK
>> passed test "import-default"
>> passed test "import-named"
>> passed test "require-default"
>> passed test "require-sub"
>> passed test "require-indirect"
Testing http://localhost:8000/tmp/test-require-indirect.webpack.html ....OK
Testing http://localhost:8000/tmp/test-require-indirect.webpack.html .....OK
>> passed test "import-default"
>> passed test "import-named"
>> passed test "require-default"
>> passed test "require-sub"
>> passed test "require-indirect"
>> 44 tests completed in 42ms, with 0 failed, 0 skipped, and 0 todo.
Testing http://localhost:8000/tmp/test-require-sub.es.html .OK
>> passed test "require-sub"
Testing http://localhost:8000/tmp/test-require-sub.iife.html .OK
>> passed test "require-sub"
Testing http://localhost:8000/tmp/test-require-sub.umd.html .OK
>> passed test "require-sub"
Testing http://localhost:8000/tmp/test-require-sub.webpack.html .OK
>> passed test "require-sub"
>> 56 tests completed in 42ms, with 0 failed, 0 skipped, and 0 todo.
Done.`;

Expand Down
1 change: 1 addition & 0 deletions demos/bundlers/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const inputs = [
`${dirname}/test/import-named.js`,
`${dirname}/test/import-indirect.js`,
`${dirname}/test/require-default.cjs`,
`${dirname}/test/require-sub.cjs`,
`${dirname}/test/require-indirect.cjs`
];

Expand Down
5 changes: 5 additions & 0 deletions demos/bundlers/test/import-indirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import './import-default.js';
import './import-named.js';
import './require-default.cjs';
import './require-sub.cjs';

import QUnit from 'qunit';

Expand All @@ -17,4 +18,8 @@ QUnit.test('import-indirect', function (assert) {
assert.strictEqual(TEST_OBJECTS.require_default, QUnit, 'identity');
assert.strictEqual(QUnit.hello_require_default, 'require-default', 'extend QUnit');
assert.strictEqual(assert.hello_require_default, 'require-default', 'extend assert');

assert.strictEqual(TEST_OBJECTS.require_sub, QUnit, 'identity');
assert.strictEqual(QUnit.hello_require_sub, 'require-sub', 'extend QUnit');
assert.strictEqual(assert.hello_require_sub, 'require-sub', 'extend assert');
});
5 changes: 5 additions & 0 deletions demos/bundlers/test/require-indirect.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const QUnit = require('qunit');
require('./import-default.js');
require('./import-named.js');
require('./require-default.cjs');
require('./require-sub.cjs');

QUnit.test('require-indirect', function (assert) {
assert.strictEqual(TEST_OBJECTS.import_default, QUnit, 'identity');
Expand All @@ -17,4 +18,8 @@ QUnit.test('require-indirect', function (assert) {
assert.strictEqual(TEST_OBJECTS.require_default, QUnit, 'identity');
assert.strictEqual(QUnit.hello_require_default, 'require-default', 'extend QUnit');
assert.strictEqual(assert.hello_require_default, 'require-default', 'extend assert');

assert.strictEqual(TEST_OBJECTS.require_sub, QUnit, 'identity');
assert.strictEqual(QUnit.hello_require_sub, 'require-sub', 'extend QUnit');
assert.strictEqual(assert.hello_require_sub, 'require-sub', 'extend assert');
});
10 changes: 10 additions & 0 deletions demos/bundlers/test/require-sub.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const QUnit = require('qunit').QUnit;
const { add } = require('./src.js');

(globalThis.TEST_OBJECTS || (globalThis.TEST_OBJECTS = {})).require_sub = QUnit;

QUnit.hello_require_sub = QUnit.assert.hello_require_sub = 'require-sub';

QUnit.test('require-sub', function (assert) {
assert.equal(add(2, 3), 5);
});

0 comments on commit 7d7eb09

Please sign in to comment.