qunitx-cli 0.0.3 → 0.1.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/flake.lock +64 -0
- package/flake.nix +26 -0
- package/lib/commands/help.js +1 -2
- package/package.json +10 -7
- package/CHANGELOG.md +0 -16
- package/Dockerfile +0 -24
- package/build.js +0 -54
- package/test/commands/help-test.js +0 -73
- package/test/commands/index.js +0 -2
- package/test/commands/init-test.js +0 -44
- package/test/flags/after-test.js +0 -23
- package/test/flags/before-test.js +0 -23
- package/test/flags/coverage-test.js +0 -6
- package/test/flags/failfast-test.js +0 -5
- package/test/flags/index.js +0 -2
- package/test/flags/output-test.js +0 -6
- package/test/flags/reporter-test.js +0 -6
- package/test/flags/timeout-test.js +0 -6
- package/test/flags/watch-test.js +0 -6
- package/test/helpers/after-script-async.js +0 -13
- package/test/helpers/after-script-basic.js +0 -1
- package/test/helpers/assert-stdout.js +0 -112
- package/test/helpers/before-script-async.js +0 -35
- package/test/helpers/before-script-basic.js +0 -1
- package/test/helpers/before-script-web-server-tests.js +0 -28
- package/test/helpers/failing-tests.js +0 -49
- package/test/helpers/failing-tests.ts +0 -49
- package/test/helpers/fs-writers.js +0 -36
- package/test/helpers/index-with-content.html +0 -20
- package/test/helpers/index-without-content.html +0 -22
- package/test/helpers/passing-tests-dist.js +0 -4883
- package/test/helpers/passing-tests.js +0 -44
- package/test/helpers/passing-tests.ts +0 -44
- package/test/helpers/shell.js +0 -37
- package/test/index.js +0 -22
- package/test/inputs/advanced-htmls-test.js +0 -21
- package/test/inputs/error-edge-cases-test.js +0 -11
- package/test/inputs/file-and-folder-test.js +0 -11
- package/test/inputs/file-test.js +0 -169
- package/test/inputs/folder-test.js +0 -193
- package/test/inputs/index.js +0 -5
- package/test/setup/index.js +0 -1
- package/test/setup/test-file-paths-test.js +0 -33
- package/test/setup.js +0 -17
package/flake.lock
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nodes": {
|
|
3
|
+
"flake-utils": {
|
|
4
|
+
"locked": {
|
|
5
|
+
"lastModified": 1659877975,
|
|
6
|
+
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
|
7
|
+
"owner": "numtide",
|
|
8
|
+
"repo": "flake-utils",
|
|
9
|
+
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
|
10
|
+
"type": "github"
|
|
11
|
+
},
|
|
12
|
+
"original": {
|
|
13
|
+
"owner": "numtide",
|
|
14
|
+
"repo": "flake-utils",
|
|
15
|
+
"type": "github"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"napalm": {
|
|
19
|
+
"inputs": {
|
|
20
|
+
"flake-utils": "flake-utils",
|
|
21
|
+
"nixpkgs": [
|
|
22
|
+
"nixpkgs"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"locked": {
|
|
26
|
+
"lastModified": 1672245824,
|
|
27
|
+
"narHash": "sha256-i596lbPiA/Rfx3DiJiCluxdgxWY7oGSgYMT7OmM+zik=",
|
|
28
|
+
"owner": "nix-community",
|
|
29
|
+
"repo": "napalm",
|
|
30
|
+
"rev": "7c25a05cef52dc405f4688422ce0046ca94aadcf",
|
|
31
|
+
"type": "github"
|
|
32
|
+
},
|
|
33
|
+
"original": {
|
|
34
|
+
"owner": "nix-community",
|
|
35
|
+
"repo": "napalm",
|
|
36
|
+
"type": "github"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"nixpkgs": {
|
|
40
|
+
"locked": {
|
|
41
|
+
"lastModified": 1690860117,
|
|
42
|
+
"narHash": "sha256-srkCfjMlg777HxDVMfhkIFgRhhtuZjIOIyR2ejLYK+Y=",
|
|
43
|
+
"owner": "NixOS",
|
|
44
|
+
"repo": "nixpkgs",
|
|
45
|
+
"rev": "96d403ee2479f2070050353b94808209f1352edb",
|
|
46
|
+
"type": "github"
|
|
47
|
+
},
|
|
48
|
+
"original": {
|
|
49
|
+
"owner": "NixOS",
|
|
50
|
+
"ref": "nixpkgs-unstable",
|
|
51
|
+
"repo": "nixpkgs",
|
|
52
|
+
"type": "github"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"root": {
|
|
56
|
+
"inputs": {
|
|
57
|
+
"napalm": "napalm",
|
|
58
|
+
"nixpkgs": "nixpkgs"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"root": "root",
|
|
63
|
+
"version": 7
|
|
64
|
+
}
|
package/flake.nix
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
description = "A flake for napalm";
|
|
3
|
+
|
|
4
|
+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
5
|
+
inputs.napalm.url = "github:nix-community/napalm";
|
|
6
|
+
|
|
7
|
+
# NOTE: This is optional, but is how to configure napalm's env
|
|
8
|
+
inputs.napalm.inputs.nixpkgs.follows = "nixpkgs";
|
|
9
|
+
|
|
10
|
+
outputs = { self, nixpkgs, napalm }:
|
|
11
|
+
let
|
|
12
|
+
system = "x86_64-linux";
|
|
13
|
+
pkgs = nixpkgs.legacyPackages."${system}";
|
|
14
|
+
in {
|
|
15
|
+
packages."${system}".default = napalm.legacyPackages."${system}".buildPackage ./. {
|
|
16
|
+
nodejs = pkgs.nodejs-slim_20;
|
|
17
|
+
PUPPETEER_SKIP_DOWNLOAD=1;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
devShells."${system}".default = pkgs.mkShell {
|
|
21
|
+
nativeBuildInputs = with pkgs; [
|
|
22
|
+
nodejs-slim_20
|
|
23
|
+
];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
package/lib/commands/help.js
CHANGED
|
@@ -20,7 +20,6 @@ ${highlight("Input options:")}
|
|
|
20
20
|
- Combination: $ ${color('qunitx test/foo.js test/bar.js test/*-test.js test/logout')}
|
|
21
21
|
|
|
22
22
|
${highlight("Optional flags:")}
|
|
23
|
-
${color('--browser')} : run qunit tests in chromium with puppeteer instead of node.js(which is the default)
|
|
24
23
|
${color('--debug')} : print console output when tests run in browser
|
|
25
24
|
${color('--watch')} : run the target file or folders, watch them for continuous run and expose http server under localhost
|
|
26
25
|
${color('--timeout')} : change default timeout per test case
|
|
@@ -29,7 +28,7 @@ ${color('--failFast')} : run the target file or folders with immediate abort if
|
|
|
29
28
|
${color('--before')} : run a script before the tests(i.e start a new web server before tests)
|
|
30
29
|
${color('--after')} : run a script after the tests(i.e save test results to a file)
|
|
31
30
|
|
|
32
|
-
${highlight("Example:")} $ ${color('qunitx test/foo.ts app/e2e --
|
|
31
|
+
${highlight("Example:")} $ ${color('qunitx test/foo.ts app/e2e --debug --watch --before=scripts/start-new-webserver.js --after=scripts/write-test-results.js')}
|
|
33
32
|
|
|
34
33
|
${highlight("Commands:")}
|
|
35
34
|
${color('$ qunitx init')} # Bootstraps qunitx base html and add qunitx config to package.json if needed
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qunitx-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "Browser runner for QUnitx: run your qunitx tests in google-chrome",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "cli.js",
|
|
7
7
|
"author": "Izel Nakri",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"keywords": [
|
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
"prepack": "npm run build",
|
|
24
24
|
"release:alpha": "node_modules/.bin/release-it --preRelease=alpha --no-git.requireUpstream",
|
|
25
25
|
"release:beta": "node_modules/.bin/release-it --preRelease=beta --no-git.requireUpstream",
|
|
26
|
-
"release": "node_modules/.bin/release-it"
|
|
26
|
+
"release": "node_modules/.bin/release-it",
|
|
27
|
+
"test": "node --test test/index.js",
|
|
28
|
+
"test:sanity-first": "./cli.js test/helpers/failing-tests.js test/helpers/failing-tests.ts",
|
|
29
|
+
"test:sanity-second": "./cli.js test/helpers/passing-tests.js test/helpers/passing-tests.ts"
|
|
27
30
|
},
|
|
28
31
|
"engines": {
|
|
29
32
|
"node": ">=20.3.0"
|
|
@@ -38,12 +41,12 @@
|
|
|
38
41
|
"dependencies": {
|
|
39
42
|
"cheerio": "^1.0.0-rc.10",
|
|
40
43
|
"chokidar": "^3.5.3",
|
|
41
|
-
"esbuild": "^0.18.
|
|
44
|
+
"esbuild": "^0.18.14",
|
|
42
45
|
"js-yaml": "^4.1.0",
|
|
43
46
|
"jsdom": "^22.0.0",
|
|
44
47
|
"kleur": "^4.1.5",
|
|
45
48
|
"picomatch": "^2.3.1",
|
|
46
|
-
"puppeteer": "20.
|
|
49
|
+
"puppeteer": "20.9.0",
|
|
47
50
|
"recursive-lookup": "1.1.0",
|
|
48
51
|
"ws": "^8.13.0"
|
|
49
52
|
},
|
|
@@ -53,8 +56,8 @@
|
|
|
53
56
|
"express": "^4.17.3",
|
|
54
57
|
"prettier": "^3.0.0",
|
|
55
58
|
"qunit": "^2.19.4",
|
|
56
|
-
"qunitx": "^0.
|
|
57
|
-
"release-it": "^16.1.
|
|
59
|
+
"qunitx": "^0.9.1",
|
|
60
|
+
"release-it": "^16.1.2"
|
|
58
61
|
},
|
|
59
62
|
"volta": {
|
|
60
63
|
"node": "20.4.0"
|
package/CHANGELOG.md
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
### Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
|
|
4
|
-
|
|
5
|
-
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
|
-
|
|
7
|
-
#### [0.0.3](https://github.com/izelnakri/qunitx-cli/compare/0.0.2...0.0.3)
|
|
8
|
-
|
|
9
|
-
- built the foundation for development [`569d860`](https://github.com/izelnakri/qunitx-cli/commit/569d8606b75287aceeaaf0b711139650182cd6c4)
|
|
10
|
-
|
|
11
|
-
#### 0.0.2
|
|
12
|
-
|
|
13
|
-
> 13 July 2023
|
|
14
|
-
|
|
15
|
-
- Release 0.0.2 [`73f444d`](https://github.com/izelnakri/qunitx-cli/commit/73f444d385dd8c08188f5a992f172bd5ff898d89)
|
|
16
|
-
- init [`4d2ac8f`](https://github.com/izelnakri/qunitx-cli/commit/4d2ac8fd98ce7a4c988f9036064a6ef592b55f8f)
|
package/Dockerfile
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
FROM node:20.4.0-slim
|
|
2
|
-
|
|
3
|
-
ENV PUPPETEER_SKIP_DOWNLOAD=true CHROME_BIN=/usr/bin/google-chrome-stable
|
|
4
|
-
|
|
5
|
-
RUN apt-get update \
|
|
6
|
-
&& apt-get install -y wget gnupg \
|
|
7
|
-
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
|
8
|
-
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
|
|
9
|
-
&& apt-get update \
|
|
10
|
-
&& apt-get install -y git libxshmfence-dev google-chrome-stable --no-install-recommends \
|
|
11
|
-
&& rm -rf /var/lib/apt/lists/*
|
|
12
|
-
|
|
13
|
-
WORKDIR /code/
|
|
14
|
-
|
|
15
|
-
ADD package.json package-lock.json /code/
|
|
16
|
-
|
|
17
|
-
RUN npm install
|
|
18
|
-
|
|
19
|
-
ADD lib /code/lib
|
|
20
|
-
ADD vendor /code/vendor
|
|
21
|
-
ADD test /code/test
|
|
22
|
-
ADD . /code/
|
|
23
|
-
|
|
24
|
-
ENTRYPOINT "/bin/bash"
|
package/build.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
|
|
3
|
-
let [qunitJS, qunitCSS, _] = await Promise.all([
|
|
4
|
-
fs.readFile('./node_modules/qunit/qunit/qunit.js'),
|
|
5
|
-
fs.readFile('./node_modules/qunit/qunit/qunit.css'),
|
|
6
|
-
fs.mkdir('./vendor', { recursive: true })
|
|
7
|
-
]);
|
|
8
|
-
|
|
9
|
-
let newQUnit = qunitJS.toString().replace(
|
|
10
|
-
'start: function start(count) {',
|
|
11
|
-
`reset: function() {
|
|
12
|
-
ProcessingQueue.finished = false;
|
|
13
|
-
globalStartCalled = false;
|
|
14
|
-
runStarted = false;
|
|
15
|
-
|
|
16
|
-
config.queue.length = 0;
|
|
17
|
-
config.modules.length = 0;
|
|
18
|
-
config.autostart = false;
|
|
19
|
-
|
|
20
|
-
Object.assign(config.stats, { total: 0, passed: 0, failed: 0, skipped: 0, todo: 0 });
|
|
21
|
-
|
|
22
|
-
[
|
|
23
|
-
"started", "updateRate", "filter", "depth", "current",
|
|
24
|
-
"pageLoaded", "timeoutHandler", "timeout", "pollution"
|
|
25
|
-
].forEach( ( key ) => delete config[ key ] );
|
|
26
|
-
|
|
27
|
-
const suiteReport = config.currentModule.suiteReport;
|
|
28
|
-
|
|
29
|
-
suiteReport.childSuites.length = 0;
|
|
30
|
-
delete suiteReport._startTime;
|
|
31
|
-
delete suiteReport._endTime;
|
|
32
|
-
|
|
33
|
-
config.modules.push( config.currentModule );
|
|
34
|
-
},
|
|
35
|
-
start: function start(count) {`);
|
|
36
|
-
|
|
37
|
-
await Promise.all([
|
|
38
|
-
fs.writeFile('./vendor/qunit.js', newQUnit),
|
|
39
|
-
fs.writeFile('./vendor/qunit.css', qunitCSS),
|
|
40
|
-
createPackageJSONIfNotExists()
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
async function createPackageJSONIfNotExists() {
|
|
44
|
-
try {
|
|
45
|
-
await fs.stat('./vendor/package.json');
|
|
46
|
-
|
|
47
|
-
return true;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
await fs.writeFile('./vendor/package.json', JSON.stringify({
|
|
50
|
-
name: 'qunitx-vendor',
|
|
51
|
-
version: '0.0.1'
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { module, test } from 'qunitx';
|
|
2
|
-
import process from "node:process";
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import { promisify } from 'node:util';
|
|
5
|
-
import { exec } from 'node:child_process';
|
|
6
|
-
|
|
7
|
-
const CWD = process.cwd();
|
|
8
|
-
const VERSION = JSON.parse(fs.readFileSync(`${CWD}/package.json`)).version;
|
|
9
|
-
const shell = promisify(exec);
|
|
10
|
-
const cli = async function(arg = '') {
|
|
11
|
-
if (process.argv[0].includes('deno')) {
|
|
12
|
-
return await shell(`deno run --allow-read --allow-env ${CWD}/deno/cli.js ${arg}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return await shell(`node ${CWD}/cli.js ${arg}`);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const printedHelpOutput = `[qunitx v${VERSION}] Usage: qunitx [targets] --$flags
|
|
19
|
-
|
|
20
|
-
Input options:
|
|
21
|
-
- File: $ qunitx test/foo.js
|
|
22
|
-
- Folder: $ qunitx test/login
|
|
23
|
-
- Globs: $ qunitx test/**/*-test.js
|
|
24
|
-
- Combination: $ qunitx test/foo.js test/bar.js test/*-test.js test/logout
|
|
25
|
-
|
|
26
|
-
Optional flags:
|
|
27
|
-
--browser : run qunit tests in chromium with puppeteer instead of node.js(which is the default)
|
|
28
|
-
--debug : print console output when tests run in browser
|
|
29
|
-
--watch : run the target file or folders, watch them for continuous run and expose http server under localhost
|
|
30
|
-
--timeout : change default timeout per test case
|
|
31
|
-
--output : folder to distribute built qunitx html and js that a webservers can run[default: tmp]
|
|
32
|
-
--failFast : run the target file or folders with immediate abort if a single test fails
|
|
33
|
-
--before : run a script before the tests(i.e start a new web server before tests)
|
|
34
|
-
--after : run a script after the tests(i.e save test results to a file)
|
|
35
|
-
|
|
36
|
-
Example: $ qunitx test/foo.ts app/e2e --browser --debug --watch --before=scripts/start-new-webserver.js --after=scripts/write-test-results.js
|
|
37
|
-
|
|
38
|
-
Commands:
|
|
39
|
-
$ qunitx init # Bootstraps qunitx base html and add qunitx config to package.json if needed
|
|
40
|
-
$ qunitx new $testFileName # Creates a qunitx test file`;
|
|
41
|
-
|
|
42
|
-
module('Commands | Help tests', () => {
|
|
43
|
-
test('$ qunitx -> prints help text', async (assert) => {
|
|
44
|
-
const { stdout } = await cli();
|
|
45
|
-
|
|
46
|
-
console.log(stdout);
|
|
47
|
-
assert.ok(stdout.includes(printedHelpOutput));
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('$ qunitx print -> prints help text', async (assert) => {
|
|
51
|
-
const { stdout } = await cli('print');
|
|
52
|
-
|
|
53
|
-
assert.ok(stdout.includes(printedHelpOutput));
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('$ qunitx p -> prints help text', async (assert) => {
|
|
57
|
-
const { stdout } = await cli('p');
|
|
58
|
-
|
|
59
|
-
assert.ok(stdout.includes(printedHelpOutput));
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('$ qunitx help -> prints help text', async (assert) => {
|
|
63
|
-
const { stdout } = await cli('help');
|
|
64
|
-
|
|
65
|
-
assert.ok(stdout.includes(printedHelpOutput));
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('$ qunitx h -> prints help text', async (assert) => {
|
|
69
|
-
const { stdout } = await cli('h');
|
|
70
|
-
|
|
71
|
-
assert.ok(stdout.includes(printedHelpOutput));
|
|
72
|
-
});
|
|
73
|
-
});
|
package/test/commands/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { module, test } from 'qunitx';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import { promisify } from 'node:util';
|
|
4
|
-
import { exec } from 'node:child_process';
|
|
5
|
-
|
|
6
|
-
const shell = promisify(exec);
|
|
7
|
-
const cli = async function(arg = '') {
|
|
8
|
-
if (process.argv[0].includes('deno')) {
|
|
9
|
-
return await shell(`deno run --allow-read ${CWD}/deno/cli.js ${arg}`);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return await shell(`deno run --allow-read ${CWD}/cli.js ${arg}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module('Commands | init tests', () => {
|
|
16
|
-
test('$ qunitx init -> creates the test.html and correctly', async () => {
|
|
17
|
-
// assert missing
|
|
18
|
-
const { stdout } = await cli('init');
|
|
19
|
-
// assert added
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// it('$ qunitx init warns existing files and assigns attributes to package.json', async function() {
|
|
23
|
-
|
|
24
|
-
// });
|
|
25
|
-
|
|
26
|
-
// it('$ qunitx init -> recreates missing files from package.json if it exists', async function() {
|
|
27
|
-
|
|
28
|
-
// });
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
async function stripQUnitXFromPackageJSON() {
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// it('$ qunitx unknown -> raises error', async function() {
|
|
36
|
-
// t.plan(2);
|
|
37
|
-
|
|
38
|
-
// try {
|
|
39
|
-
// await shell(`node ${process.cwd()}/cli.js dasd`);
|
|
40
|
-
// } catch ({ stdout }) {
|
|
41
|
-
// assert.ok(stdout.includes('qunitx unknown command. Available options are:'));
|
|
42
|
-
// assert.ok(stdout.includes(printedHelpOutput));
|
|
43
|
-
// }
|
|
44
|
-
// });
|
package/test/flags/after-test.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { module, test } from 'qunitx';
|
|
2
|
-
import { assertPassingTestCase, assertFailingTestCase, assertTAPResult } from '../helpers/assert-stdout.js';
|
|
3
|
-
import shell from '../helpers/shell.js';
|
|
4
|
-
|
|
5
|
-
module('--after script tests for browser mode', { concurrency: false }, (_hooks, moduleMetadata) => {
|
|
6
|
-
test('--after works when it doesnt need to be awaited', async (assert, testMetadata) => {
|
|
7
|
-
const { stdout } = await shell('node cli.js test/helpers/passing-tests.js --after=test/helpers/after-script-basic.js', { ...moduleMetadata, ...testMetadata });
|
|
8
|
-
|
|
9
|
-
assert.ok(stdout.includes('This is running from after script!!'));
|
|
10
|
-
assertPassingTestCase(assert, stdout, { debug: false, testNo: 1, moduleName: '{{moduleName}}' });
|
|
11
|
-
assertTAPResult(assert, stdout, { testCount: 3 });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('--after works when it needs to be awaited', async (assert, testMetadata) => {
|
|
15
|
-
const { stdout } = await shell('node cli.js test/helpers/passing-tests.js --after=test/helpers/after-script-async.js', { ...moduleMetadata, ...testMetadata });
|
|
16
|
-
|
|
17
|
-
assert.ok(stdout.includes('This is running from after script!!'));
|
|
18
|
-
assert.ok(stdout.includes('After script result is written:'));
|
|
19
|
-
assert.ok(stdout.includes(JSON.stringify({ testCount: 3, failCount: 0, skipCount: 0, passCount: 3 }, null, 2)));
|
|
20
|
-
assertPassingTestCase(assert, stdout, { testNo: 1, moduleName: '{{moduleName}}' });
|
|
21
|
-
assertTAPResult(assert, stdout, { testCount: 3 });
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { module, test } from 'qunitx';
|
|
2
|
-
import { assertPassingTestCase, assertFailingTestCase, assertTAPResult } from '../helpers/assert-stdout.js';
|
|
3
|
-
import shell from '../helpers/shell.js';
|
|
4
|
-
|
|
5
|
-
module('--before script tests for browser mode', { concurrency: false }, (_hooks, moduleMetadata) => {
|
|
6
|
-
test('--before works when it doesnt need to be awaited', async (assert, testMetadata) => {
|
|
7
|
-
const { stdout } = await shell('node cli.js test/helpers/passing-tests.js --before=test/helpers/before-script-basic.js', { ...moduleMetadata, ...testMetadata });
|
|
8
|
-
|
|
9
|
-
assert.ok(stdout.includes('This is running from before script!!'));
|
|
10
|
-
assertPassingTestCase(assert, stdout, { testNo: 1, moduleName: '{{moduleName}}' });
|
|
11
|
-
assertTAPResult(assert, stdout, { testCount: 3 });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('--before works it needs to be awaited', { concurrency: false }, async (assert, testMetadata) => {
|
|
15
|
-
const { stdout } = await shell('node cli.js test/helpers/passing-tests.js test/helpers/before-script-web-server-tests.js --before=test/helpers/before-script-async.js', { ...moduleMetadata, ...testMetadata });
|
|
16
|
-
|
|
17
|
-
assert.ok(stdout.includes('This is running from before script!!'));
|
|
18
|
-
assert.ok(stdout.includes('Starting before script with:'));
|
|
19
|
-
assertPassingTestCase(assert, stdout, { testNo: 1, moduleName: '{{moduleName}}' });
|
|
20
|
-
assertPassingTestCase(assert, stdout, { testNo: 4, moduleName: '{{moduleName}} Before script web server tests' });
|
|
21
|
-
assertTAPResult(assert, stdout, { testCount: 4 });
|
|
22
|
-
});
|
|
23
|
-
});
|
package/test/flags/index.js
DELETED
package/test/flags/watch-test.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import './after-script-basic.js';
|
|
3
|
-
|
|
4
|
-
export default async function(results) {
|
|
5
|
-
let resultsInString = JSON.stringify(results, null, 2);
|
|
6
|
-
|
|
7
|
-
await fs.rm(`${process.cwd()}/tmp/results.json`, { force: true, recursive: true });
|
|
8
|
-
await fs.writeFile(`${process.cwd()}/tmp/results.json`, resultsInString);
|
|
9
|
-
|
|
10
|
-
console.log('After script result is written:');
|
|
11
|
-
console.log(resultsInString);
|
|
12
|
-
}
|
|
13
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('This is running from after script!!');
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
export function assertStdout(assert, folderNames, options={ checkFailure: false, debug: false }) {
|
|
2
|
-
// folderNames.forEach((folder
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function assertPassingTestCase(assert, stdout, options={ moduleName: '{{moduleName}}', debug: false }) {
|
|
6
|
-
let { moduleName, debug } = options;
|
|
7
|
-
|
|
8
|
-
if (debug) {
|
|
9
|
-
assert.ok(new RegExp(`ok \. ${moduleName} | assert.ok works # (\d+ ms)`).test(stdout));
|
|
10
|
-
assert.ok(stdout.includes('resolving async test'));
|
|
11
|
-
assert.ok(/(.+)placeholder(.+)/g.test(stdout));
|
|
12
|
-
assert.ok(/(.+)anotherObject(.+)/g.test(stdout));
|
|
13
|
-
assert.ok(new RegExp(`ok \. ${moduleName} | async test finishes # (\d+ ms)`).test(stdout));
|
|
14
|
-
assert.ok(stdout.includes('calling deepEqual test case'));
|
|
15
|
-
// assert.ok(new RegExp(`ok ${testNo++} ${moduleName} | deepEqual true works # (\d+ ms)`).test(stdout));
|
|
16
|
-
} else {
|
|
17
|
-
assert.ok(new RegExp(`ok \. ${moduleName} | assert.ok works # (\d+ ms)`).test(stdout));
|
|
18
|
-
assert.ok(new RegExp(`ok \. ${moduleName} | async test finishes # (\d+ ms)`).test(stdout));
|
|
19
|
-
// assert.ok(new RegExp(`ok ${testNo++} ${moduleName} | deepEqual true works # (\d+ ms)`).test(stdout));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function assertFailingTestCase(assert, stdout, options={ moduleName: '{{moduleName}}', debug: false }) {
|
|
24
|
-
let { moduleName, debug } = options;
|
|
25
|
-
|
|
26
|
-
if (debug) {
|
|
27
|
-
assert.ok(stdout.includes('calling assert true test case'));
|
|
28
|
-
assert.ok(stdout.includes('resolving async test'));
|
|
29
|
-
assert.ok(/(.+)placeholder(.+)/g.test(stdout));
|
|
30
|
-
assert.ok(/(.+)anotherObject(.+)/g.test(stdout));
|
|
31
|
-
} else {
|
|
32
|
-
assert.ok(!stdout.includes('calling assert true test case'));
|
|
33
|
-
assert.ok(!stdout.includes('resolving async test'));
|
|
34
|
-
assert.notOk(/(.+)placeholder(.+)/g.test(stdout));
|
|
35
|
-
assert.notOk(/(.+)anotherObject(.+)/g.test(stdout));
|
|
36
|
-
|
|
37
|
-
assert.ok(new RegExp(`not ok 2 ${moduleName} | async test finishes # (\d+ ms)␊
|
|
38
|
-
---␊
|
|
39
|
-
name: 'Assertion #1'␊
|
|
40
|
-
actual: null␊
|
|
41
|
-
expected: null␊
|
|
42
|
-
message: 'Promise rejected during "async test finishes": wait is not a function'␊
|
|
43
|
-
stack: |-␊
|
|
44
|
-
TypeError: wait is not a function␊
|
|
45
|
-
at Object.<anonymous> (\S+:\d+:\d+)␊
|
|
46
|
-
at: '\S+:\d+:\d+'␊
|
|
47
|
-
...␊
|
|
48
|
-
---␊
|
|
49
|
-
name: 'Assertion #2'␊
|
|
50
|
-
actual: null␊
|
|
51
|
-
expected: null␊
|
|
52
|
-
message: 'Expected 4 assertions, but 1 were run'␊
|
|
53
|
-
stack: ' at Object.<anonymous> (\S+:\d+:\d+)'␊
|
|
54
|
-
at: '\S+:\d+:\d+'␊
|
|
55
|
-
...`).test(stdout));
|
|
56
|
-
assert.ok(new RegExp(`not ok 3 ${moduleName} | runtime error output # (\d+ ms)
|
|
57
|
-
---
|
|
58
|
-
name: 'Assertion #1'
|
|
59
|
-
actual: null
|
|
60
|
-
expected: true
|
|
61
|
-
message: null
|
|
62
|
-
stack: ' at Object.<anonymous> (\S+:\d+:\d+)'
|
|
63
|
-
at: '\S+:\d+:\d+'
|
|
64
|
-
...
|
|
65
|
-
---
|
|
66
|
-
name: 'Assertion #2'
|
|
67
|
-
actual: null
|
|
68
|
-
expected: null
|
|
69
|
-
message: >-
|
|
70
|
-
Died on test #2 at Object.<anonymous>
|
|
71
|
-
(\S+:\d+:\d+): Cannot
|
|
72
|
-
read property 'second' of undefined
|
|
73
|
-
stack: |-
|
|
74
|
-
TypeError: Cannot read property 'second' of undefined
|
|
75
|
-
at Object.<anonymous> (\S+:\d+:\d+)
|
|
76
|
-
at: '\S+:\d+:\d+'
|
|
77
|
-
...
|
|
78
|
-
`).test(stdout));
|
|
79
|
-
assert.ok(new RegExp(`not ok 4 ${moduleName} | deepEqual true works # (\d+ ms)␊
|
|
80
|
-
---␊
|
|
81
|
-
name: 'Assertion #1'␊
|
|
82
|
-
actual:␊
|
|
83
|
-
firstName: Izel␊
|
|
84
|
-
lastName: Nakri␊
|
|
85
|
-
expected:␊
|
|
86
|
-
firstName: Isaac␊
|
|
87
|
-
lastName: Nakri␊
|
|
88
|
-
message: null␊
|
|
89
|
-
stack: ' at Object.<anonymous> (\S+:\d+:\d+)'␊
|
|
90
|
-
at: '\S+:\d+:\d+'␊
|
|
91
|
-
...␊`).test(stdout));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function assertTAPResult(assert, stdout, options={ testCount: 0, failCount: 0 }) {
|
|
96
|
-
if (options.failCount) {
|
|
97
|
-
return assert.ok(new RegExp(`# pass ${options.testCount - options.failCount}
|
|
98
|
-
# skip 0
|
|
99
|
-
# fail (${options.failCount}|${options.failCount + 1})`).test(stdout));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
assert.ok(new RegExp(`# pass ${options.testCount}
|
|
103
|
-
# skip 0
|
|
104
|
-
# fail 0`).test(stdout));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export default {
|
|
108
|
-
assertStdout,
|
|
109
|
-
assertPassingTestCase,
|
|
110
|
-
assertFailingTestCase,
|
|
111
|
-
assertTAPResult
|
|
112
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import cors from "cors";
|
|
3
|
-
import kleur from 'kleur';
|
|
4
|
-
import bindServerToPort from '../../lib/setup/bind-server-to-port.js';
|
|
5
|
-
import './before-script-basic.js';
|
|
6
|
-
import QUnit from '../../index.js';
|
|
7
|
-
|
|
8
|
-
export default async function(config) {
|
|
9
|
-
console.log('Starting before script with:');
|
|
10
|
-
|
|
11
|
-
let hasServerRunning = !!config.expressApp;
|
|
12
|
-
|
|
13
|
-
config.expressApp = config.expressApp || express();
|
|
14
|
-
config.expressApp.use(cors());
|
|
15
|
-
config.expressApp.get("/films", (req, res) => {
|
|
16
|
-
console.log('req received');
|
|
17
|
-
res.json({ film: "responsed correctly" });
|
|
18
|
-
});
|
|
19
|
-
config.expressApp.get("/movies/too-big-to-fail", (req, res) => {
|
|
20
|
-
res.json({ movie: "is too-big-to-fail" });
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (!hasServerRunning) {
|
|
24
|
-
console.log('DOESNT HAVE SERVER RUNNING');
|
|
25
|
-
let server = await bindServerToPort(config.expressApp, config);
|
|
26
|
-
|
|
27
|
-
QUnit.config.port = config.port;
|
|
28
|
-
console.log(`Web server started on port ${QUnit.config.port}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function wait(duration) {
|
|
33
|
-
return new Promise((resolve) => setTimeout(() => { resolve() }, duration));
|
|
34
|
-
}
|
|
35
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('This is running from before script!!');
|