qunitx-cli 0.9.1 → 0.9.3
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/{cli.js → cli.ts} +16 -8
- package/deno.lock +20 -14
- package/lib/commands/{generate.js → generate.ts} +5 -5
- package/lib/commands/{help.js → help.ts} +1 -1
- package/lib/commands/{init.js → init.ts} +26 -27
- package/lib/commands/run/{tests-in-browser.js → tests-in-browser.ts} +51 -22
- package/lib/commands/{run.js → run.ts} +100 -39
- package/lib/servers/{http.js → http.ts} +88 -35
- package/lib/setup/bind-server-to-port.ts +14 -0
- package/lib/setup/{browser.js → browser.ts} +14 -18
- package/lib/setup/config.ts +55 -0
- package/lib/setup/{file-watcher.js → file-watcher.ts} +21 -8
- package/lib/setup/{fs-tree.js → fs-tree.ts} +6 -4
- package/lib/setup/{keyboard-events.js → keyboard-events.ts} +10 -5
- package/lib/setup/{test-file-paths.js → test-file-paths.ts} +10 -4
- package/lib/setup/{web-server.js → web-server.ts} +22 -21
- package/lib/setup/{write-output-static-files.js → write-output-static-files.ts} +6 -2
- package/lib/tap/{display-final-result.js → display-final-result.ts} +6 -3
- package/lib/tap/{display-test-result.js → display-test-result.ts} +25 -11
- package/lib/tap/{dump-yaml.js → dump-yaml.ts} +19 -5
- package/lib/types.ts +61 -0
- package/lib/utils/{chromium-args.js → chromium-args.ts} +1 -1
- package/lib/utils/{color.js → color.ts} +24 -11
- package/lib/utils/{early-chrome.js → early-chrome.ts} +5 -5
- package/lib/utils/{find-chrome.js → find-chrome.ts} +2 -2
- package/lib/utils/{find-internal-assets-from-html.js → find-internal-assets-from-html.ts} +1 -1
- package/lib/utils/{find-project-root.js → find-project-root.ts} +4 -4
- package/lib/utils/{indent-string.js → indent-string.ts} +6 -2
- package/lib/utils/{listen-to-keyboard-key.js → listen-to-keyboard-key.ts} +12 -7
- package/lib/utils/{parse-cli-flags.js → parse-cli-flags.ts} +21 -8
- package/lib/utils/{path-exists.js → path-exists.ts} +2 -2
- package/lib/utils/{perf-logger.js → perf-logger.ts} +1 -1
- package/lib/utils/pre-launch-chrome.ts +45 -0
- package/lib/utils/{read-boilerplate.js → read-boilerplate.ts} +1 -1
- package/lib/utils/{resolve-port-number-for.js → resolve-port-number-for.ts} +2 -2
- package/lib/utils/{run-user-module.js → run-user-module.ts} +6 -2
- package/lib/utils/{search-in-parent-directories.js → search-in-parent-directories.ts} +5 -2
- package/lib/utils/{time-counter.js → time-counter.ts} +2 -2
- package/package.json +16 -15
- package/lib/setup/bind-server-to-port.js +0 -9
- package/lib/setup/config.js +0 -48
- package/lib/utils/pre-launch-chrome.js +0 -32
- /package/lib/setup/{default-project-config-values.js → default-project-config-values.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qunitx-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.3",
|
|
5
5
|
"description": "Browser runner for QUnitx: run your qunitx tests in google-chrome",
|
|
6
|
-
"main": "cli.
|
|
6
|
+
"main": "cli.ts",
|
|
7
7
|
"author": "Izel Nakri",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"keywords": [
|
|
@@ -15,27 +15,27 @@
|
|
|
15
15
|
"qunitx"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"bin": "chmod +x cli.
|
|
19
|
-
"format": "prettier --check \"lib/**/*.
|
|
20
|
-
"format:fix": "prettier --write \"lib/**/*.
|
|
21
|
-
"lint": "deno lint lib/ cli.
|
|
18
|
+
"bin": "chmod +x cli.ts && ./cli.ts",
|
|
19
|
+
"format": "prettier --check \"lib/**/*.ts\" \"test/**/*.ts\" \"*.ts\" \"package.json\" \".github/**/*.yml\"",
|
|
20
|
+
"format:fix": "prettier --write \"lib/**/*.ts\" \"test/**/*.ts\" \"*.ts\" \"package.json\" \".github/**/*.yml\"",
|
|
21
|
+
"lint": "deno lint lib/ cli.ts",
|
|
22
22
|
"lint:docs": "node scripts/lint-docs.js",
|
|
23
|
-
"docs": "deno doc --html --name=\"qunitx-cli\" --output=docs/lib 'lib/**/*.
|
|
23
|
+
"docs": "deno doc --html --name=\"qunitx-cli\" --output=docs/lib 'lib/**/*.ts' README.md",
|
|
24
24
|
"changelog:unreleased": "git-cliff --unreleased --strip all",
|
|
25
25
|
"changelog:preview": "git-cliff",
|
|
26
26
|
"changelog:update": "git-cliff --output CHANGELOG.md",
|
|
27
27
|
"postinstall": "deno install --allow-scripts=npm:playwright-core || true",
|
|
28
|
-
"test": "node test/setup.
|
|
29
|
-
"test:browser": "node test/setup.
|
|
30
|
-
"test:sanity-first": "./cli.
|
|
31
|
-
"test:sanity-second": "./cli.
|
|
28
|
+
"test": "node --experimental-strip-types test/setup.ts && FORCE_COLOR=0 node --experimental-strip-types --test --test-concurrency=$(node -p 'require(\"os\").availableParallelism()') test/**/*-test.ts",
|
|
29
|
+
"test:browser": "node --experimental-strip-types test/setup.ts && FORCE_COLOR=0 node --experimental-strip-types --test --test-concurrency=$(node -p 'require(\"os\").availableParallelism()') test/flags/*-test.ts test/inputs/*-test.ts",
|
|
30
|
+
"test:sanity-first": "./cli.ts test/helpers/failing-tests.js test/helpers/failing-tests.ts",
|
|
31
|
+
"test:sanity-second": "./cli.ts test/helpers/passing-tests.js test/helpers/passing-tests.ts"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=24.0.0",
|
|
35
35
|
"deno": ">=2.7.0"
|
|
36
36
|
},
|
|
37
37
|
"bin": {
|
|
38
|
-
"qunitx": "cli.
|
|
38
|
+
"qunitx": "cli.ts"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
@@ -43,16 +43,17 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"esbuild": "^0.27.3",
|
|
46
|
-
"picomatch": "^4.0.
|
|
46
|
+
"picomatch": "^4.0.4",
|
|
47
47
|
"playwright-core": "^1.58.2",
|
|
48
|
-
"ws": "^8.
|
|
48
|
+
"ws": "^8.20.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"cors": "^2.8.6",
|
|
52
52
|
"express": "^5.2.1",
|
|
53
53
|
"js-yaml": "^4.1.1",
|
|
54
54
|
"prettier": "^3.8.1",
|
|
55
|
-
"qunitx": "^1.0.
|
|
55
|
+
"qunitx": "^1.0.4",
|
|
56
|
+
"typescript": "^5.0.0"
|
|
56
57
|
},
|
|
57
58
|
"volta": {
|
|
58
59
|
"node": "24.14.0"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Binds an HTTPServer to an OS-assigned port and writes the resolved port back to `config.port`.
|
|
3
|
-
* @returns {Promise<object>}
|
|
4
|
-
*/
|
|
5
|
-
export default async function bindServerToPort(server, config) {
|
|
6
|
-
await server.listen(0);
|
|
7
|
-
config.port = server._server.address().port;
|
|
8
|
-
return server;
|
|
9
|
-
}
|
package/lib/setup/config.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import defaultProjectConfigValues from './default-project-config-values.js';
|
|
3
|
-
import findProjectRoot from '../utils/find-project-root.js';
|
|
4
|
-
import setupFSTree from './fs-tree.js';
|
|
5
|
-
import setupTestFilePaths from './test-file-paths.js';
|
|
6
|
-
import parseCliFlags from '../utils/parse-cli-flags.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Builds the merged qunitx config from package.json settings and CLI flags.
|
|
10
|
-
* @returns {Promise<object>}
|
|
11
|
-
*/
|
|
12
|
-
export default async function setupConfig() {
|
|
13
|
-
const projectRoot = await findProjectRoot();
|
|
14
|
-
const cliConfigFlags = parseCliFlags(projectRoot);
|
|
15
|
-
const projectPackageJSON = await readConfigFromPackageJSON(projectRoot);
|
|
16
|
-
const inputs = cliConfigFlags.inputs.concat(readInputsFromPackageJSON(projectPackageJSON));
|
|
17
|
-
const config = {
|
|
18
|
-
...defaultProjectConfigValues,
|
|
19
|
-
htmlPaths: [],
|
|
20
|
-
...projectPackageJSON.qunitx,
|
|
21
|
-
...cliConfigFlags,
|
|
22
|
-
projectRoot,
|
|
23
|
-
inputs,
|
|
24
|
-
testFileLookupPaths: setupTestFilePaths(projectRoot, inputs),
|
|
25
|
-
lastFailedTestFiles: null,
|
|
26
|
-
lastRanTestFiles: null,
|
|
27
|
-
};
|
|
28
|
-
config.htmlPaths = normalizeHTMLPaths(config.projectRoot, config.htmlPaths);
|
|
29
|
-
config.fsTree = await setupFSTree(config.testFileLookupPaths, config);
|
|
30
|
-
|
|
31
|
-
return config;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function readConfigFromPackageJSON(projectRoot) {
|
|
35
|
-
const packageJSON = await fs.readFile(`${projectRoot}/package.json`);
|
|
36
|
-
|
|
37
|
-
return JSON.parse(packageJSON.toString());
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function normalizeHTMLPaths(projectRoot, htmlPaths) {
|
|
41
|
-
return Array.from(new Set(htmlPaths.map((htmlPath) => `${projectRoot}/${htmlPath}`)));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function readInputsFromPackageJSON(packageJSON) {
|
|
45
|
-
const qunitx = packageJSON.qunitx;
|
|
46
|
-
|
|
47
|
-
return qunitx && qunitx.inputs ? qunitx.inputs : [];
|
|
48
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
|
|
3
|
-
const CDP_URL_REGEX = /DevTools listening on (ws:\/\/[^\s]+)/;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Spawns a headless Chrome process with remote-debugging-port=0 and resolves once the
|
|
7
|
-
* CDP WebSocket endpoint is printed to stderr. Returns null if Chrome is unavailable or
|
|
8
|
-
* fails to start, so callers can fall back to playwright's normal launch.
|
|
9
|
-
* @returns {Promise<{proc: ChildProcess, cdpEndpoint: string} | null>}
|
|
10
|
-
*/
|
|
11
|
-
export default function preLaunchChrome(chromePath, args) {
|
|
12
|
-
if (!chromePath) return Promise.resolve(null);
|
|
13
|
-
|
|
14
|
-
return new Promise((resolve) => {
|
|
15
|
-
const proc = spawn(chromePath, ['--remote-debugging-port=0', '--headless=new', ...args], {
|
|
16
|
-
stdio: ['ignore', 'ignore', 'pipe'],
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
let buffer = '';
|
|
20
|
-
proc.stderr.on('data', (chunk) => {
|
|
21
|
-
buffer += chunk.toString();
|
|
22
|
-
const match = buffer.match(CDP_URL_REGEX);
|
|
23
|
-
if (match) resolve({ proc, cdpEndpoint: match[1] });
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Resolve null on any startup failure so launchBrowser falls back to chromium.launch()
|
|
27
|
-
proc.on('error', () => resolve(null));
|
|
28
|
-
proc.on('close', (code) => {
|
|
29
|
-
if (code !== null && code !== 0) resolve(null);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
File without changes
|