qunitx 0.3.8 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/run/tests-in-browser.js +9 -0
- package/lib/commands/run.js +9 -4
- package/lib/setup/browser.js +1 -1
- package/lib/setup/web-server.js +17 -2
- package/lol.js +4 -0
- package/package.json +11 -8
- package/shims/nodejs-assert.js +28 -0
- package/shims/nodejs.js +71 -0
- package/test-output.log +1095 -0
|
@@ -119,7 +119,9 @@ function buildFilteredTests(filteredTests, outputPath) {
|
|
|
119
119
|
|
|
120
120
|
async function runTestInsideHTMLFile(filePath, { page, server }, config) {
|
|
121
121
|
let QUNIT_RESULT;
|
|
122
|
+
let targetError;
|
|
122
123
|
try {
|
|
124
|
+
await wait(350);
|
|
123
125
|
console.log('#', kleur.blue(`QUnitX running: http://localhost:${server.config.port}${filePath}`));
|
|
124
126
|
await page.goto(`http://localhost:${server.config.port}${filePath}`, { timeout: 0 });
|
|
125
127
|
await page.evaluate(() => {
|
|
@@ -129,16 +131,19 @@ async function runTestInsideHTMLFile(filePath, { page, server }, config) {
|
|
|
129
131
|
|
|
130
132
|
QUNIT_RESULT = await page.evaluate(() => window.QUNIT_RESULT);
|
|
131
133
|
} catch(error) {
|
|
134
|
+
targetError = error;
|
|
132
135
|
console.log(error);
|
|
133
136
|
console.error(error);
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
if (!QUNIT_RESULT || QUNIT_RESULT.totalTests === 0) {
|
|
140
|
+
console.log(targetError);
|
|
137
141
|
console.log('BROWSER: runtime error thrown during executing tests');
|
|
138
142
|
console.error('BROWSER: runtime error thrown during executing tests');
|
|
139
143
|
|
|
140
144
|
await failOnNonWatchMode(config.watch);
|
|
141
145
|
} else if (QUNIT_RESULT.totalTests > QUNIT_RESULT.finishedTests) {
|
|
146
|
+
console.log(targetError);
|
|
142
147
|
console.log(`BROWSER: TEST TIMED OUT: ${QUNIT_RESULT.currentTest}`);
|
|
143
148
|
console.error(`BROWSER: TEST TIMED OUT: ${QUNIT_RESULT.currentTest}`);
|
|
144
149
|
|
|
@@ -151,3 +156,7 @@ async function failOnNonWatchMode(watchMode = false) {
|
|
|
151
156
|
await new Promise((resolve, reject) => setTimeout(() => resolve(process.exit(1)), 100));
|
|
152
157
|
}
|
|
153
158
|
}
|
|
159
|
+
|
|
160
|
+
function wait(duration) {
|
|
161
|
+
return new Promise((resolve) => setTimeout(() => { resolve() }, duration));
|
|
162
|
+
}
|
package/lib/commands/run.js
CHANGED
|
@@ -16,21 +16,22 @@ import writeOutputStaticFiles from '../setup/write-output-static-files.js';
|
|
|
16
16
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
17
|
|
|
18
18
|
export default async function(config) {
|
|
19
|
-
if (config.before) {
|
|
20
|
-
await runUserModule(`${process.cwd()}/${config.before}`, config, 'before');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
19
|
if (config.browser) {
|
|
24
20
|
let cachedContent = await buildCachedContent(config, config.htmlPaths);
|
|
25
21
|
let [connections, _] = await Promise.all([
|
|
26
22
|
setupBrowser(config, cachedContent),
|
|
27
23
|
writeOutputStaticFiles(config, cachedContent)
|
|
28
24
|
]);
|
|
25
|
+
config.expressApp = connections.server;
|
|
29
26
|
|
|
30
27
|
if (config.watch) {
|
|
31
28
|
setupKeyboardEvents(config, cachedContent, connections);
|
|
32
29
|
}
|
|
33
30
|
|
|
31
|
+
if (config.before) {
|
|
32
|
+
await runUserModule(`${process.cwd()}/${config.before}`, config, 'before');
|
|
33
|
+
}
|
|
34
|
+
|
|
34
35
|
await runTestsInBrowser(config, cachedContent, connections);
|
|
35
36
|
|
|
36
37
|
if (config.watch) {
|
|
@@ -60,6 +61,10 @@ export default async function(config) {
|
|
|
60
61
|
setupKeyboardEvents(config);
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
if (config.before) {
|
|
65
|
+
await runUserModule(`${process.cwd()}/${config.before}`, config, 'before');
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
await runTestsInNode(Object.keys(config.fsTree), config);
|
|
64
69
|
|
|
65
70
|
if (config.watch) {
|
package/lib/setup/browser.js
CHANGED
|
@@ -11,7 +11,7 @@ export default async function setupBrowser(config = {
|
|
|
11
11
|
setupWebServer(config, cachedContent),
|
|
12
12
|
Puppeteer.launch({
|
|
13
13
|
executablePath: process.env.CHROME_BIN || null,
|
|
14
|
-
headless:
|
|
14
|
+
headless: 'new',
|
|
15
15
|
args: ['--no-sandbox', '--disable-gpu', '--remote-debugging-port=0', '--window-size=1440,900']
|
|
16
16
|
}),
|
|
17
17
|
]);
|
package/lib/setup/web-server.js
CHANGED
|
@@ -194,14 +194,29 @@ function testRuntimeToInject(port, config) {
|
|
|
194
194
|
});
|
|
195
195
|
window.QUnit.done((details) => {
|
|
196
196
|
if (window.IS_PUPPETEER) {
|
|
197
|
-
window.
|
|
197
|
+
window.setTimeout(() => {
|
|
198
|
+
window.socket.send(JSON.stringify({ event: 'done', details: details, abort: window.abortQUnit }))
|
|
199
|
+
}, 50);
|
|
198
200
|
}
|
|
199
201
|
window.setTimeout(() => {
|
|
200
202
|
window.testTimeout = ${config.timeout};
|
|
201
203
|
}, 75);
|
|
202
204
|
});
|
|
203
205
|
|
|
204
|
-
|
|
206
|
+
if ([1, 3].includes(window.socket.readyState)) {
|
|
207
|
+
return window.setTimeout(() => window.QUnit.start(), 10);
|
|
208
|
+
} else {
|
|
209
|
+
let connectionTrialCount = 0;
|
|
210
|
+
let connectionInterval = window.setInterval(() => {
|
|
211
|
+
if ([1, 3].includes(window.socket.readyState) || connectionTrialCount > 10) {
|
|
212
|
+
window.clearInterval(connectionInterval);
|
|
213
|
+
|
|
214
|
+
return window.setTimeout(() => window.QUnit.start(), 10);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
connectionTrialCount = connectionTrialCount + 1;
|
|
218
|
+
}, 10);
|
|
219
|
+
}
|
|
205
220
|
}
|
|
206
221
|
|
|
207
222
|
setupQUnit();
|
package/lol.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qunitx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"description": "Experimental improvements, suggestions for qunit CLI",
|
|
6
6
|
"author": "Izel Nakri",
|
|
7
7
|
"license": "MIT",
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"qunit",
|
|
10
10
|
"qunit-plugin"
|
|
11
11
|
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20.1.0"
|
|
14
|
+
},
|
|
12
15
|
"main": "index.js",
|
|
13
16
|
"bin": {
|
|
14
17
|
"qunitx": "cli.js"
|
|
@@ -28,7 +31,7 @@
|
|
|
28
31
|
"release:alpha": "node_modules/.bin/release-it --preRelease=alpha --no-git.requireUpstream",
|
|
29
32
|
"release:beta": "node_modules/.bin/release-it --preRelease=beta --no-git.requireUpstream",
|
|
30
33
|
"release": "node_modules/.bin/release-it",
|
|
31
|
-
"test": "node --test test/index.js",
|
|
34
|
+
"test": "node --test test/index.js | tee test-output.log",
|
|
32
35
|
"test:old": "node_modules/.bin/mocha --require test/setup.js --bail --exit --check-leaks test/inputs test/commands test/flags/after-test.js test/flags/before-test.js -t=20000",
|
|
33
36
|
"test:sanity-first": "./cli.js test/helpers/failing-tests.js test/helpers/failing-tests.ts",
|
|
34
37
|
"test:sanity-second": "./cli.js test/helpers/passing-tests.js test/helpers/passing-tests.ts"
|
|
@@ -37,13 +40,13 @@
|
|
|
37
40
|
"@nanoexpress/middleware-static-serve": "^1.0.4",
|
|
38
41
|
"cheerio": "^1.0.0-rc.10",
|
|
39
42
|
"chokidar": "^3.5.3",
|
|
40
|
-
"esbuild": "^0.
|
|
43
|
+
"esbuild": "^0.17.18",
|
|
41
44
|
"js-yaml": "^4.1.0",
|
|
42
45
|
"kleur": "^4.1.5",
|
|
43
|
-
"nanoexpress": "^6.1
|
|
46
|
+
"nanoexpress": "^6.2.1",
|
|
44
47
|
"picomatch": "^2.3.1",
|
|
45
|
-
"puppeteer": "
|
|
46
|
-
"recursive-lookup": "1.
|
|
48
|
+
"puppeteer": "20.1.2",
|
|
49
|
+
"recursive-lookup": "1.1.0",
|
|
47
50
|
"ts-node": "^10.7.0"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
@@ -52,11 +55,11 @@
|
|
|
52
55
|
"express": "^4.17.3",
|
|
53
56
|
"prettier": "^2.8.8",
|
|
54
57
|
"qunit": "^2.18.0",
|
|
55
|
-
"qunitx": "^0.3.
|
|
58
|
+
"qunitx": "^0.3.8",
|
|
56
59
|
"release-it": "^15.10.3"
|
|
57
60
|
},
|
|
58
61
|
"volta": {
|
|
59
|
-
"node": "
|
|
62
|
+
"node": "20.1.0"
|
|
60
63
|
},
|
|
61
64
|
"prettier": {
|
|
62
65
|
"printWidth": 100,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
|
|
3
|
+
// TODO: write test cases for these
|
|
4
|
+
export default {
|
|
5
|
+
async: assert.async,
|
|
6
|
+
deepEqual: assert.deepStrictEqual,
|
|
7
|
+
equal: assert.strictEqual,
|
|
8
|
+
expect: assert.expect,
|
|
9
|
+
false: assert.false,
|
|
10
|
+
notDeepEqual: assert.notDeepStrictEqual,
|
|
11
|
+
notEqual: assert.notEqual,
|
|
12
|
+
notOk(state, message) {
|
|
13
|
+
return assert.ok(!state, message);
|
|
14
|
+
},
|
|
15
|
+
notPropContains: assert.notPropContains,
|
|
16
|
+
notPropEqual: assert.notPropEqual,
|
|
17
|
+
notStrictEqual: assert.notStrictEqual,
|
|
18
|
+
ok: assert.ok,
|
|
19
|
+
propContains: assert.propContains,
|
|
20
|
+
pushResult: assert.pushResult,
|
|
21
|
+
rejects: assert.rejects,
|
|
22
|
+
step: assert.step,
|
|
23
|
+
strictEqual: assert.strictEqual,
|
|
24
|
+
throws: assert.throws,
|
|
25
|
+
timeout: assert.timeout,
|
|
26
|
+
true: assert.true,
|
|
27
|
+
verifySteps: assert.verifySteps
|
|
28
|
+
};
|
package/shims/nodejs.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { run, describe, it, before, after, beforeEach, afterEach } from 'node:test';
|
|
2
|
+
import assert from './nodejs-assert.js';
|
|
3
|
+
|
|
4
|
+
export const module = async function(moduleName, runtimeOptions, moduleContent) {
|
|
5
|
+
let targetRuntimeOptions = moduleContent ? runtimeOptions : {};
|
|
6
|
+
let targetModuleContent = moduleContent ? moduleContent : runtimeOptions;
|
|
7
|
+
|
|
8
|
+
return describe(moduleName, assignDefaultValues(targetRuntimeOptions, { concurrency: true }), async function() {
|
|
9
|
+
return await targetModuleContent({ before, after, beforeEach, afterEach }, {
|
|
10
|
+
moduleName,
|
|
11
|
+
options: runtimeOptions
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const test = async function(testName, runtimeOptions, testContent) {
|
|
17
|
+
let targetRuntimeOptions = testContent ? runtimeOptions : {};
|
|
18
|
+
let targetTestContent = testContent ? testContent : runtimeOptions;
|
|
19
|
+
|
|
20
|
+
return it(testName, assignDefaultValues(targetRuntimeOptions, { concurrency: true }), async function() {
|
|
21
|
+
return await targetTestContent(assert, { testName, options: runtimeOptions });
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function assignDefaultValues(options, defaultValues) {
|
|
26
|
+
for (let key in defaultValues) {
|
|
27
|
+
if (options[key] === undefined) {
|
|
28
|
+
options[key] = defaultValues[key];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// NOTE: later maybe expose these as well:
|
|
34
|
+
|
|
35
|
+
// import QUnit from './vendor/qunit.js';
|
|
36
|
+
|
|
37
|
+
// QUnit.config.autostart = false;
|
|
38
|
+
|
|
39
|
+
// export const isLocal = QUnit.isLocal;
|
|
40
|
+
// export const on = QUnit.on;
|
|
41
|
+
// export const test = QUnit.test;
|
|
42
|
+
// export const skip = QUnit.skip;
|
|
43
|
+
// export const start = QUnit.start;
|
|
44
|
+
// export const is = QUnit.is;
|
|
45
|
+
// export const extend = QUnit.extend;
|
|
46
|
+
// export const stack = QUnit.stack;
|
|
47
|
+
// export const onUnhandledRejection = QUnit.onUnhandledRejection;
|
|
48
|
+
// export const assert = QUnit.assert;
|
|
49
|
+
// export const dump = QUnit.dump;
|
|
50
|
+
// export const done = QUnit.done;
|
|
51
|
+
// export const testStart = QUnit.testStart;
|
|
52
|
+
// export const moduleStart = QUnit.moduleStart;
|
|
53
|
+
// export const version = QUnit.version;
|
|
54
|
+
// export const module = QUnit.module;
|
|
55
|
+
// export const todo = QUnit.todo;
|
|
56
|
+
// export const only = QUnit.only;
|
|
57
|
+
// export const config = QUnit.config;
|
|
58
|
+
// export const objectType = QUnit.objectType;
|
|
59
|
+
// export const load = QUnit.load;
|
|
60
|
+
// export const onError = QUnit.onError;
|
|
61
|
+
// export const pushFailure = QUnit.pushFailure;
|
|
62
|
+
// export const equiv = QUnit.equiv;
|
|
63
|
+
// export const begin = QUnit.begin;
|
|
64
|
+
// export const log = QUnit.log;
|
|
65
|
+
// export const testDone = QUnit.testDone;
|
|
66
|
+
// export const moduleDone = QUnit.moduleDone;
|
|
67
|
+
// export const diff = QUnit.diff;
|
|
68
|
+
|
|
69
|
+
// export default Object.assign(QUnit, {
|
|
70
|
+
// QUnitxVersion: '0.0.1'
|
|
71
|
+
// });
|