qunitx-cli 0.0.2 → 0.1.0
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/.github/dependabot.yml +7 -0
- package/.github/workflows/push.yml +36 -0
- package/CHANGELOG.md +16 -0
- package/Dockerfile +24 -0
- package/LICENSE +22 -0
- package/TODO +90 -0
- package/build.js +54 -1
- package/cli.js +24 -1
- package/lib/boilerplates/default-project-config-values.js +6 -0
- package/lib/boilerplates/setup/tests.hbs +15 -0
- package/lib/boilerplates/setup/tsconfig.json +109 -0
- package/lib/boilerplates/test.js +25 -0
- package/lib/commands/generate.js +33 -0
- package/lib/commands/help.js +37 -0
- package/lib/commands/init.js +70 -0
- package/lib/commands/run/tests-in-browser.js +162 -0
- package/lib/commands/run.js +119 -0
- package/lib/servers/http.js +233 -0
- package/lib/setup/bind-server-to-port.js +14 -0
- package/lib/setup/browser.js +55 -0
- package/lib/setup/config.js +46 -0
- package/lib/setup/file-watcher.js +72 -0
- package/lib/setup/fs-tree.js +48 -0
- package/lib/setup/keyboard-events.js +34 -0
- package/lib/setup/test-file-paths.js +79 -0
- package/lib/setup/web-server.js +241 -0
- package/lib/setup/write-output-static-files.js +22 -0
- package/lib/tap/display-final-result.js +15 -0
- package/lib/tap/display-test-result.js +73 -0
- package/lib/utils/find-internal-assets-from-html.js +16 -0
- package/lib/utils/find-project-root.js +17 -0
- package/lib/utils/indent-string.js +11 -0
- package/lib/utils/listen-to-keyboard-key.js +44 -0
- package/lib/utils/parse-cli-flags.js +57 -0
- package/lib/utils/path-exists.js +11 -0
- package/lib/utils/resolve-port-number-for.js +27 -0
- package/lib/utils/run-user-module.js +18 -0
- package/lib/utils/search-in-parent-directories.js +15 -0
- package/lib/utils/time-counter.js +8 -0
- package/package.json +8 -5
- package/test/commands/help-test.js +72 -0
- package/test/commands/index.js +2 -0
- package/test/commands/init-test.js +44 -0
- package/test/flags/after-test.js +23 -0
- package/test/flags/before-test.js +23 -0
- package/test/flags/coverage-test.js +6 -0
- package/test/flags/failfast-test.js +5 -0
- package/test/flags/index.js +2 -0
- package/test/flags/output-test.js +6 -0
- package/test/flags/reporter-test.js +6 -0
- package/test/flags/timeout-test.js +6 -0
- package/test/flags/watch-test.js +6 -0
- package/test/helpers/after-script-async.js +13 -0
- package/test/helpers/after-script-basic.js +1 -0
- package/test/helpers/assert-stdout.js +112 -0
- package/test/helpers/before-script-async.js +35 -0
- package/test/helpers/before-script-basic.js +1 -0
- package/test/helpers/before-script-web-server-tests.js +28 -0
- package/test/helpers/failing-tests.js +49 -0
- package/test/helpers/failing-tests.ts +49 -0
- package/test/helpers/fs-writers.js +36 -0
- package/test/helpers/index-with-content.html +20 -0
- package/test/helpers/index-without-content.html +22 -0
- package/test/helpers/passing-tests-dist.js +4883 -0
- package/test/helpers/passing-tests.js +44 -0
- package/test/helpers/passing-tests.ts +44 -0
- package/test/helpers/shell.js +37 -0
- package/test/index.js +22 -0
- package/test/inputs/advanced-htmls-test.js +21 -0
- package/test/inputs/error-edge-cases-test.js +11 -0
- package/test/inputs/file-and-folder-test.js +11 -0
- package/test/inputs/file-test.js +169 -0
- package/test/inputs/folder-test.js +193 -0
- package/test/inputs/index.js +5 -0
- package/test/setup/index.js +1 -0
- package/test/setup/test-file-paths-test.js +33 -0
- package/test/setup.js +17 -0
- package/vendor/package.json +1 -0
- package/vendor/qunit.css +525 -0
- package/vendor/qunit.js +7037 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
|
|
4
|
+
export async function writeTestFolder(options={ addFailingTests: false, mixedExtensions: false }) {
|
|
5
|
+
let { addFailingTests, mixedExtensions } = options;
|
|
6
|
+
let folderName = crypto.randomUUID();
|
|
7
|
+
let extension = mixedExtensions ? 'ts' : 'js';
|
|
8
|
+
let [passingsTestTemplate, failingTestTemplate] = await Promise.all([
|
|
9
|
+
fs.readFile(`${process.cwd()}/test/helpers/passing-tests.js`),
|
|
10
|
+
options.addFailingTests ? fs.readFile(`${process.cwd()}/test/helpers/failing-tests.js`) : null,
|
|
11
|
+
fs.mkdir(`${process.cwd()}/tmp/${folderName}`, { recursive: true })
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
await Promise.all([
|
|
15
|
+
writeTestFile(folderName, 'first-module-pass', 'js', passingsTestTemplate),
|
|
16
|
+
writeTestFile(folderName, 'second-module-pass', extension, passingsTestTemplate),
|
|
17
|
+
addFailingTests ? writeTestFile(folderName, 'first-module-fail', 'js', failingTestTemplate) : null,
|
|
18
|
+
addFailingTests ? writeTestFile(folderName, 'second-module-fail', extension, failingTestTemplate) : null,
|
|
19
|
+
addFailingTests ? writeTestFile(folderName, 'third-module-fail', extension, failingTestTemplate) : null,
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
return folderName;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function writeTestFile(folderName, testFileName, extension, templateBuffer) {
|
|
27
|
+
return fs.writeFile(
|
|
28
|
+
`${process.cwd()}/tmp/${folderName}/${testFileName}.${extension}`,
|
|
29
|
+
templateBuffer.toString().replace('{{moduleName}}', `${folderName} | ${testFileName}`)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
writeTestFolder,
|
|
35
|
+
writeTestFile
|
|
36
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width">
|
|
6
|
+
<title>HTML with content tests</title>
|
|
7
|
+
<link href="../../node_modules/qunit/qunit/qunit.css" rel="stylesheet">
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="qunit"></div>
|
|
11
|
+
<div id="qunit-fixture"></div>
|
|
12
|
+
|
|
13
|
+
{{content}}
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
console.log('Hello from index-with-content.html');
|
|
17
|
+
</script>
|
|
18
|
+
<script src="./passing-tests-dist.js"></script>
|
|
19
|
+
</body>
|
|
20
|
+
</html>`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width">
|
|
6
|
+
<title>HTML without content tests</title>
|
|
7
|
+
<link href="../../node_modules/qunit/qunit/qunit.css" rel="stylesheet">
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="qunit"></div>
|
|
11
|
+
<div id="qunit-fixture"></div>
|
|
12
|
+
|
|
13
|
+
<!-- this has no {content} so should be just viewed in the browser with no console interaction(?) -->
|
|
14
|
+
<script>
|
|
15
|
+
console.log('Hello from index-without-content.html');
|
|
16
|
+
</script>
|
|
17
|
+
<script src="./passing-tests-dist.js"></script>
|
|
18
|
+
<script>
|
|
19
|
+
window.QUnit.start();
|
|
20
|
+
</script>
|
|
21
|
+
</body>
|
|
22
|
+
</html>`
|