qunitx-cli 0.1.0 → 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.
Files changed (46) hide show
  1. package/flake.lock +64 -0
  2. package/flake.nix +26 -0
  3. package/package.json +4 -4
  4. package/.github/dependabot.yml +0 -7
  5. package/.github/workflows/push.yml +0 -36
  6. package/CHANGELOG.md +0 -25
  7. package/Dockerfile +0 -24
  8. package/TODO +0 -90
  9. package/build.js +0 -54
  10. package/test/commands/help-test.js +0 -72
  11. package/test/commands/index.js +0 -2
  12. package/test/commands/init-test.js +0 -44
  13. package/test/flags/after-test.js +0 -23
  14. package/test/flags/before-test.js +0 -23
  15. package/test/flags/coverage-test.js +0 -6
  16. package/test/flags/failfast-test.js +0 -5
  17. package/test/flags/index.js +0 -2
  18. package/test/flags/output-test.js +0 -6
  19. package/test/flags/reporter-test.js +0 -6
  20. package/test/flags/timeout-test.js +0 -6
  21. package/test/flags/watch-test.js +0 -6
  22. package/test/helpers/after-script-async.js +0 -13
  23. package/test/helpers/after-script-basic.js +0 -1
  24. package/test/helpers/assert-stdout.js +0 -112
  25. package/test/helpers/before-script-async.js +0 -35
  26. package/test/helpers/before-script-basic.js +0 -1
  27. package/test/helpers/before-script-web-server-tests.js +0 -28
  28. package/test/helpers/failing-tests.js +0 -49
  29. package/test/helpers/failing-tests.ts +0 -49
  30. package/test/helpers/fs-writers.js +0 -36
  31. package/test/helpers/index-with-content.html +0 -20
  32. package/test/helpers/index-without-content.html +0 -22
  33. package/test/helpers/passing-tests-dist.js +0 -4883
  34. package/test/helpers/passing-tests.js +0 -44
  35. package/test/helpers/passing-tests.ts +0 -44
  36. package/test/helpers/shell.js +0 -37
  37. package/test/index.js +0 -22
  38. package/test/inputs/advanced-htmls-test.js +0 -21
  39. package/test/inputs/error-edge-cases-test.js +0 -11
  40. package/test/inputs/file-and-folder-test.js +0 -11
  41. package/test/inputs/file-test.js +0 -169
  42. package/test/inputs/folder-test.js +0 -193
  43. package/test/inputs/index.js +0 -5
  44. package/test/setup/index.js +0 -1
  45. package/test/setup/test-file-paths-test.js +0 -33
  46. package/test/setup.js +0 -17
@@ -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 'qunitx';
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!!');
@@ -1,28 +0,0 @@
1
- import { module, test } from 'qunitx';
2
-
3
- module('{{moduleName}} Before script web server tests', function(hooks) {
4
- test('assert true works', async function (assert) {
5
- let json;
6
- try {
7
- let port = window.QUnit.config.port || location.port;
8
-
9
- await wait(250);
10
-
11
- let res = await fetch(`http://127.0.0.1:${port}/films`);
12
- json = await res.json();
13
- } catch (err) {
14
- console.log('FETCH ERR', err);
15
- console.log(err.cause);
16
- }
17
-
18
- assert.deepEqual(json, { film: 'responsed correctly' });
19
- });
20
-
21
- // test('async test finishes', async function (assert) {
22
-
23
- // });
24
- });
25
-
26
- function wait(duration) {
27
- return new Promise((resolve) => setTimeout(() => { resolve() }, duration));
28
- }
@@ -1,49 +0,0 @@
1
- import { module, test } from 'qunitx';
2
-
3
- module('{{moduleName}} Failing Tests', function(hooks) {
4
- test('assert true works', function (assert) {
5
- assert.expect(3);
6
- assert.ok(true);
7
- console.log('calling assert true test case');
8
- assert.equal(true, true);
9
- assert.equal(null, null);
10
- });
11
-
12
- test('async test finishes', async function (assert) {
13
- assert.expect(4);
14
-
15
- const wait = () => new Promise((resolve, reject) => {
16
- window.setTimeout(() => {
17
- console.log('resolving async test');
18
- console.log({
19
- moduleName: 'called resolved async test with object',
20
- placeholder: 1000,
21
- anotherObject: {
22
- firstName: 'Izel',
23
- createdAt: new Date('2021-03-06')
24
- }
25
- });
26
- resolve(true);
27
- }, 50);
28
- });
29
- const result = await wait();
30
-
31
- assert.ok(true);
32
- assert.equal(false, result);
33
- assert.equal(null, null);
34
- });
35
-
36
- test('runtime error output', function (assert) {
37
- let smt = {};
38
-
39
- assert.equal(undefined, true);
40
- assert.deepEqual(smt.first.second, {});
41
- });
42
-
43
- test('deepEqual true works', function (assert) {
44
- const me = { firstName: 'Izel', lastName: 'Nakri' };
45
-
46
- console.log('calling deepEqual test case');
47
- assert.deepEqual(me, { firstName: 'Isaac', lastName: 'Nakri' });
48
- });
49
- });
@@ -1,49 +0,0 @@
1
- import { module, test } from 'qunitx';
2
-
3
- module('{{moduleName}} Failing Tests', function(hooks) {
4
- test('assert true works', function (assert) {
5
- assert.expect(3);
6
- assert.ok(true);
7
- console.log('calling assert true test case');
8
- assert.equal(true, true);
9
- assert.equal(null, null);
10
- });
11
-
12
- test('async test finishes', async function (assert) {
13
- assert.expect(4);
14
-
15
- const wait = () => new Promise((resolve, reject) => {
16
- window.setTimeout(() => {
17
- console.log('resolving async test');
18
- console.log({
19
- moduleName: 'called resolved async test with object',
20
- placeholder: 1000,
21
- anotherObject: {
22
- firstName: 'Izel',
23
- createdAt: new Date('2021-03-06')
24
- }
25
- });
26
- resolve(true);
27
- }, 50);
28
- });
29
- const result = await wait();
30
-
31
- assert.ok(true);
32
- assert.equal(false, result);
33
- assert.equal(null, null);
34
- });
35
-
36
- test('runtime error output', function (assert) {
37
- let smt = {};
38
-
39
- assert.equal(undefined, true);
40
- assert.deepEqual(smt.first.second, {});
41
- });
42
-
43
- test('deepEqual true works', function (assert) {
44
- const me = { firstName: 'Izel', lastName: 'Nakri' };
45
-
46
- console.log('calling deepEqual test case');
47
- assert.deepEqual(me, { firstName: 'Isaac', lastName: 'Nakri' });
48
- });
49
- });
@@ -1,36 +0,0 @@
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
- };
@@ -1,20 +0,0 @@
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>`
@@ -1,22 +0,0 @@
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>`