qunitx 0.7.0 → 0.8.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/build.js +54 -0
- package/deno.json +2 -2
- package/deno.lock +0 -3752
- package/package.json +20 -40
- package/{index.js → shims/browser/index.js} +2 -4
- package/shims/{deno.js → deno/index.js} +1 -1
- package/shims/{nodejs.js → node/index.js} +1 -1
- package/vendor/package.json +1 -4
- package/cli.js +0 -25
- package/deno/cli.js +0 -21
- package/lib/boilerplates/default-project-config-values.js +0 -6
- package/lib/boilerplates/setup/tests.hbs +0 -15
- package/lib/boilerplates/setup/tsconfig.json +0 -109
- package/lib/boilerplates/test.js +0 -25
- package/lib/commands/generate.js +0 -33
- package/lib/commands/help.js +0 -38
- package/lib/commands/init.js +0 -70
- package/lib/commands/run/tests-in-browser.js +0 -162
- package/lib/commands/run.js +0 -119
- package/lib/servers/http.js +0 -233
- package/lib/setup/bind-server-to-port.js +0 -14
- package/lib/setup/browser.js +0 -55
- package/lib/setup/config.js +0 -46
- package/lib/setup/file-watcher.js +0 -72
- package/lib/setup/fs-tree.js +0 -48
- package/lib/setup/keyboard-events.js +0 -34
- package/lib/setup/test-file-paths.js +0 -79
- package/lib/setup/web-server.js +0 -241
- package/lib/setup/write-output-static-files.js +0 -22
- package/lib/tap/display-final-result.js +0 -15
- package/lib/tap/display-test-result.js +0 -73
- package/lib/utils/find-internal-assets-from-html.js +0 -16
- package/lib/utils/find-project-root.js +0 -17
- package/lib/utils/indent-string.js +0 -11
- package/lib/utils/listen-to-keyboard-key.js +0 -44
- package/lib/utils/parse-cli-flags.js +0 -57
- package/lib/utils/path-exists.js +0 -11
- package/lib/utils/resolve-port-number-for.js +0 -27
- package/lib/utils/run-user-module.js +0 -18
- package/lib/utils/search-in-parent-directories.js +0 -15
- package/lib/utils/time-counter.js +0 -8
- /package/shims/{deno-assert.js → deno/assert.js} +0 -0
- /package/shims/{nodejs-assert.js → node/assert.js} +0 -0
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qunitx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.8.0",
|
|
5
|
+
"description": "Framework testing any js file on node.js, browser or deno with QUnit API",
|
|
6
6
|
"author": "Izel Nakri",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"keywords": [
|
|
9
|
+
"test",
|
|
10
|
+
"test framework",
|
|
11
|
+
"testing",
|
|
9
12
|
"qunit",
|
|
10
|
-
"
|
|
13
|
+
"node",
|
|
14
|
+
"deno",
|
|
15
|
+
"browser"
|
|
11
16
|
],
|
|
12
17
|
"engines": {
|
|
13
18
|
"node": ">=20.3.0"
|
|
14
19
|
},
|
|
15
|
-
"bin": {
|
|
16
|
-
"qunitx": "cli.js"
|
|
17
|
-
},
|
|
18
20
|
"imports": {
|
|
19
21
|
"qunitx": {
|
|
20
|
-
"node": "./shims/
|
|
21
|
-
"deno": "./shims/deno.js",
|
|
22
|
-
"default": "./index.js"
|
|
22
|
+
"node": "./shims/node/index.js",
|
|
23
|
+
"deno": "./shims/deno/index.js",
|
|
24
|
+
"default": "./shims/browser/index.js"
|
|
23
25
|
}
|
|
24
26
|
},
|
|
25
27
|
"exports": {
|
|
26
|
-
"node": "./shims/
|
|
27
|
-
"deno": "./shims/deno.js",
|
|
28
|
-
"default": "./index.js"
|
|
28
|
+
"node": "./shims/node/index.js",
|
|
29
|
+
"deno": "./shims/deno/index.js",
|
|
30
|
+
"default": "./shims/browser/index.js"
|
|
29
31
|
},
|
|
30
32
|
"repository": {
|
|
31
33
|
"type": "git",
|
|
32
34
|
"url": "https://github.com/izelnakri/qunitx.git"
|
|
33
35
|
},
|
|
34
36
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"run": "
|
|
39
|
-
"run:node": "node cli.js",
|
|
40
|
-
"run:deno": "deno run --allow-read deno/cli.js",
|
|
37
|
+
"build": "node build.js",
|
|
38
|
+
"run:all": "npm run run:node && npm run run:deno",
|
|
39
|
+
"run:node": "node --test test/helpers/passing-tests.js && node --test test/helpers/failing-tests.js",
|
|
40
|
+
"run:deno": "deno test test/helpers/passing-tests.js && deno test test/helpers/failing-tests.js",
|
|
41
41
|
"changelog:unreleased": "node_modules/.bin/auto-changelog --stdout --commit-limit false --package --unreleased-only --hide-credit --sort-commits date-desc",
|
|
42
42
|
"changelog:preview": "node_modules/.bin/auto-changelog --stdout --commit-limit false --package -u --sort-commits date-desc",
|
|
43
43
|
"changelog:update": "node_modules/.bin/auto-changelog --commit-limit false --package --sort-commits date-desc",
|
|
@@ -47,33 +47,13 @@
|
|
|
47
47
|
"release": "node_modules/.bin/release-it",
|
|
48
48
|
"test": "node --test test/index.js",
|
|
49
49
|
"test:deno": "deno test --allow-read --allow-env --allow-run test/commands/index.js",
|
|
50
|
-
"test:dev": "node --test test/index.js | tee test-output.log"
|
|
51
|
-
"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",
|
|
52
|
-
"test:sanity-first": "./cli.js test/helpers/failing-tests.js test/helpers/failing-tests.ts",
|
|
53
|
-
"test:sanity-second": "./cli.js test/helpers/passing-tests.js test/helpers/passing-tests.ts"
|
|
54
|
-
},
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"cheerio": "^1.0.0-rc.10",
|
|
57
|
-
"chokidar": "^3.5.3",
|
|
58
|
-
"esbuild": "^0.18.12",
|
|
59
|
-
"js-yaml": "^4.1.0",
|
|
60
|
-
"jsdom": "^22.0.0",
|
|
61
|
-
"kleur": "^4.1.5",
|
|
62
|
-
"picomatch": "^2.3.1",
|
|
63
|
-
"puppeteer": "20.8.2",
|
|
64
|
-
"recursive-lookup": "1.1.0",
|
|
65
|
-
"ws": "^8.13.0"
|
|
66
|
-
},
|
|
67
|
-
"peerDependencies": {
|
|
68
|
-
"ts-node": ">=10.7.0"
|
|
50
|
+
"test:dev": "node --test test/index.js | tee test-output.log"
|
|
69
51
|
},
|
|
70
52
|
"devDependencies": {
|
|
53
|
+
"ts-node": ">=10.7.0",
|
|
71
54
|
"auto-changelog": "^2.4.0",
|
|
72
|
-
"cors": "^2.8.5",
|
|
73
|
-
"express": "^4.17.3",
|
|
74
55
|
"prettier": "^3.0.0",
|
|
75
56
|
"qunit": "^2.19.4",
|
|
76
|
-
"qunitx": "^0.6.0",
|
|
77
57
|
"release-it": "^16.1.0"
|
|
78
58
|
},
|
|
79
59
|
"volta": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import QUnit from '
|
|
1
|
+
import QUnit from '../../vendor/qunit.js';
|
|
2
2
|
|
|
3
3
|
QUnit.config.autostart = false;
|
|
4
4
|
|
|
@@ -32,6 +32,4 @@ export const testDone = QUnit.testDone;
|
|
|
32
32
|
export const moduleDone = QUnit.moduleDone;
|
|
33
33
|
export const diff = QUnit.diff;
|
|
34
34
|
|
|
35
|
-
export default
|
|
36
|
-
QUnitxVersion: '0.0.1'
|
|
37
|
-
});
|
|
35
|
+
export default QUnit;
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
describe,
|
|
7
7
|
it,
|
|
8
8
|
} from "https://deno.land/std@0.192.0/testing/bdd.ts";
|
|
9
|
-
import assert from './
|
|
9
|
+
import assert from './assert.js';
|
|
10
10
|
|
|
11
11
|
// TODO: TEST beforeEach, before, afterEach, after, currently not sure if they work!
|
|
12
12
|
export const module = async function(moduleName, runtimeOptions, moduleContent) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { run, describe, it, before, after, beforeEach, afterEach } from 'node:test';
|
|
2
|
-
import assert from './
|
|
2
|
+
import assert from './assert.js';
|
|
3
3
|
|
|
4
4
|
export const module = async function(moduleName, runtimeOptions, moduleContent) {
|
|
5
5
|
let targetRuntimeOptions = moduleContent ? runtimeOptions : {};
|
package/vendor/package.json
CHANGED
package/cli.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S TS_NODE_COMPILER_OPTIONS='{"module":"ES2020"}' node --loader ts-node/esm/transpile-only
|
|
2
|
-
import process from 'node:process';
|
|
3
|
-
import displayHelpOutput from './lib/commands/help.js';
|
|
4
|
-
import initializeProject from './lib/commands/init.js';
|
|
5
|
-
import generateTestFiles from './lib/commands/generate.js';
|
|
6
|
-
import run from './lib/commands/run.js';
|
|
7
|
-
import setupConfig from './lib/setup/config.js';
|
|
8
|
-
|
|
9
|
-
process.title = 'qunitx';
|
|
10
|
-
|
|
11
|
-
(async () => {
|
|
12
|
-
if (!process.argv[2]) {
|
|
13
|
-
return await displayHelpOutput();
|
|
14
|
-
} else if (['help', 'h', 'p', 'print'].includes(process.argv[2])) {
|
|
15
|
-
return await displayHelpOutput();
|
|
16
|
-
} else if (['new', 'n', 'g', 'generate'].includes(process.argv[2])) {
|
|
17
|
-
return await generateTestFiles();
|
|
18
|
-
} else if (['init'].includes(process.argv[2])) {
|
|
19
|
-
return await initializeProject();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let config = await setupConfig();
|
|
23
|
-
|
|
24
|
-
return await run(config);
|
|
25
|
-
})();
|
package/deno/cli.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import displayHelpOutput from '../lib/commands/help.js';
|
|
3
|
-
|
|
4
|
-
process.title = 'qunitx';
|
|
5
|
-
|
|
6
|
-
(async () => {
|
|
7
|
-
if (!process.argv[2]) {
|
|
8
|
-
return await displayHelpOutput();
|
|
9
|
-
} else if (['help', 'h', 'p', 'print'].includes(process.argv[2])) {
|
|
10
|
-
return await displayHelpOutput();
|
|
11
|
-
}
|
|
12
|
-
// else if (['new', 'n', 'g', 'generate'].includes(process.argv[2])) {
|
|
13
|
-
// return await generateTestFiles();
|
|
14
|
-
// } else if (['init'].includes(process.argv[2])) {
|
|
15
|
-
// return await initializeProject();
|
|
16
|
-
// }
|
|
17
|
-
|
|
18
|
-
// let config = await setupConfig();
|
|
19
|
-
|
|
20
|
-
// return await run(config);
|
|
21
|
-
})();
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width">
|
|
6
|
-
<title>{{applicationName}} Tests</title>
|
|
7
|
-
<link href="../node_modules/qunitx/vendor/qunit.css" rel="stylesheet">
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="qunit"></div>
|
|
11
|
-
<div id="qunit-fixture"></div>
|
|
12
|
-
|
|
13
|
-
{{content}}
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Projects */
|
|
6
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
-
|
|
13
|
-
/* Language and Environment */
|
|
14
|
-
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
-
|
|
27
|
-
/* Modules */
|
|
28
|
-
"module": "NodeNext", /* Specify what module code is generated. */
|
|
29
|
-
// "rootDir": ".", /* Specify the root folder within your source files. */
|
|
30
|
-
"moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
-
|
|
46
|
-
/* JavaScript Support */
|
|
47
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
-
|
|
51
|
-
/* Emit */
|
|
52
|
-
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
-
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
59
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
67
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
68
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
69
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
70
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
71
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
72
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
73
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
74
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
|
-
|
|
76
|
-
/* Interop Constraints */
|
|
77
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
81
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
82
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
83
|
-
|
|
84
|
-
/* Type Checking */
|
|
85
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
86
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
87
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
88
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
89
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
90
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
91
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
92
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
93
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
94
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
95
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
102
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
103
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
104
|
-
|
|
105
|
-
/* Completeness */
|
|
106
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
|
-
}
|
|
109
|
-
}
|
package/lib/boilerplates/test.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { module, test } from 'qunitx';
|
|
2
|
-
|
|
3
|
-
module('{{moduleName}}', function(hooks) {
|
|
4
|
-
test('assert true works', function (assert) {
|
|
5
|
-
assert.expect(3);
|
|
6
|
-
assert.ok(true);
|
|
7
|
-
assert.equal(true, true);
|
|
8
|
-
assert.deepEqual({}, {});
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('async test finishes', async function (assert) {
|
|
12
|
-
assert.expect(3);
|
|
13
|
-
|
|
14
|
-
let wait = () => new Promise((resolve, reject) => {
|
|
15
|
-
setTimeout(() => resolve(true), 50);
|
|
16
|
-
});
|
|
17
|
-
let result = await wait();
|
|
18
|
-
|
|
19
|
-
assert.ok(true);
|
|
20
|
-
assert.equal(true, result);
|
|
21
|
-
|
|
22
|
-
await wait();
|
|
23
|
-
assert.equal(true, result);
|
|
24
|
-
});
|
|
25
|
-
});
|
package/lib/commands/generate.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import kleur from 'kleur';
|
|
5
|
-
import findProjectRoot from '../utils/find-project-root.js';
|
|
6
|
-
import pathExists from '../utils/path-exists.js';
|
|
7
|
-
|
|
8
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
|
|
10
|
-
export default async function() {
|
|
11
|
-
let projectRoot = await findProjectRoot();
|
|
12
|
-
let moduleName = process.argv[3]; // TODO: classify this maybe in future
|
|
13
|
-
let path = process.argv[3].endsWith('.js') || process.argv[3].endsWith('.ts')
|
|
14
|
-
? `${projectRoot}/${process.argv[3]}`
|
|
15
|
-
: `${projectRoot}/${process.argv[3]}.js`;
|
|
16
|
-
|
|
17
|
-
if (await pathExists(path)) {
|
|
18
|
-
return console.log(`${path} already exists!`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let testJSContent = await fs.readFile(`${__dirname}/../boilerplates/test.js`);
|
|
22
|
-
let targetFolderPaths = path.split('/');
|
|
23
|
-
|
|
24
|
-
targetFolderPaths.pop();
|
|
25
|
-
|
|
26
|
-
await fs.mkdir(targetFolderPaths.join('/'), { recursive: true });
|
|
27
|
-
await fs.writeFile(
|
|
28
|
-
path,
|
|
29
|
-
testJSContent.toString().replace('{{moduleName}}', moduleName)
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
console.log(kleur.green(`${path} written`));
|
|
33
|
-
}
|
package/lib/commands/help.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import kleur from 'kleur';
|
|
5
|
-
|
|
6
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const highlight = (text) => kleur.magenta().bold(text);
|
|
8
|
-
const color = (text) => kleur.blue(text);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default async function() {
|
|
12
|
-
const config = JSON.parse((await fs.readFile(`${__dirname}/../../package.json`)));
|
|
13
|
-
|
|
14
|
-
console.log(`${highlight("[qunitx v" + config.version + "] Usage:")} qunitx ${color('[targets] --$flags')}
|
|
15
|
-
|
|
16
|
-
${highlight("Input options:")}
|
|
17
|
-
- File: $ ${color('qunitx test/foo.js')}
|
|
18
|
-
- Folder: $ ${color('qunitx test/login')}
|
|
19
|
-
- Globs: $ ${color('qunitx test/**/*-test.js')}
|
|
20
|
-
- Combination: $ ${color('qunitx test/foo.js test/bar.js test/*-test.js test/logout')}
|
|
21
|
-
|
|
22
|
-
${highlight("Optional flags:")}
|
|
23
|
-
${color('--browser')} : run qunit tests in chromium with puppeteer instead of node.js(which is the default)
|
|
24
|
-
${color('--debug')} : print console output when tests run in browser
|
|
25
|
-
${color('--watch')} : run the target file or folders, watch them for continuous run and expose http server under localhost
|
|
26
|
-
${color('--timeout')} : change default timeout per test case
|
|
27
|
-
${color('--output')} : folder to distribute built qunitx html and js that a webservers can run[default: tmp]
|
|
28
|
-
${color('--failFast')} : run the target file or folders with immediate abort if a single test fails
|
|
29
|
-
${color('--before')} : run a script before the tests(i.e start a new web server before tests)
|
|
30
|
-
${color('--after')} : run a script after the tests(i.e save test results to a file)
|
|
31
|
-
|
|
32
|
-
${highlight("Example:")} $ ${color('qunitx test/foo.ts app/e2e --browser --debug --watch --before=scripts/start-new-webserver.js --after=scripts/write-test-results.js')}
|
|
33
|
-
|
|
34
|
-
${highlight("Commands:")}
|
|
35
|
-
${color('$ qunitx init')} # Bootstraps qunitx base html and add qunitx config to package.json if needed
|
|
36
|
-
${color('$ qunitx new $testFileName')} # Creates a qunitx test file
|
|
37
|
-
`);
|
|
38
|
-
}
|
package/lib/commands/init.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path, { dirname } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import findProjectRoot from '../utils/find-project-root.js';
|
|
5
|
-
import pathExists from '../utils/path-exists.js';
|
|
6
|
-
import defaultProjectConfigValues from '../boilerplates/default-project-config-values.js';
|
|
7
|
-
|
|
8
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
|
|
10
|
-
export default async function() {
|
|
11
|
-
let projectRoot = await findProjectRoot();
|
|
12
|
-
let oldPackageJSON = JSON.parse(await fs.readFile(`${projectRoot}/package.json`));
|
|
13
|
-
let htmlPaths = process.argv.slice(2).reduce((result, arg) => {
|
|
14
|
-
if (arg.endsWith('.html')) {
|
|
15
|
-
result.push(arg);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return result;
|
|
19
|
-
}, oldPackageJSON.qunitx && oldPackageJSON.qunitx.htmlPaths ? oldPackageJSON.qunitx.htmlPaths : []);
|
|
20
|
-
let newQunitxConfig = Object.assign(
|
|
21
|
-
defaultProjectConfigValues,
|
|
22
|
-
htmlPaths.length > 0 ? { htmlPaths } : { htmlPaths: ['test/tests.html'] },
|
|
23
|
-
oldPackageJSON.qunitx
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
await Promise.all([
|
|
27
|
-
writeTestsHTML(projectRoot, newQunitxConfig, oldPackageJSON),
|
|
28
|
-
rewritePackageJSON(projectRoot, newQunitxConfig, oldPackageJSON),
|
|
29
|
-
writeTSConfigIfNeeded(projectRoot)
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function writeTestsHTML(projectRoot, newQunitxConfig, oldPackageJSON) {
|
|
34
|
-
let testHTMLTemplateBuffer = await fs.readFile(`${__dirname}/../boilerplates/setup/tests.hbs`);
|
|
35
|
-
|
|
36
|
-
return await Promise.all(newQunitxConfig.htmlPaths.map(async (htmlPath) => {
|
|
37
|
-
let targetPath = `${projectRoot}/${htmlPath}`;
|
|
38
|
-
if (await pathExists(targetPath)) {
|
|
39
|
-
return console.log(`${htmlPath} already exists`);
|
|
40
|
-
} else {
|
|
41
|
-
let targetDirectory = path.dirname(targetPath);
|
|
42
|
-
let targetOutputPath = path.relative(targetDirectory, `${projectRoot}/${newQunitxConfig.output}/tests.js`);
|
|
43
|
-
let testHTMLTemplate = testHTMLTemplateBuffer
|
|
44
|
-
.toString()
|
|
45
|
-
.replace('{{applicationName}}', oldPackageJSON.name);
|
|
46
|
-
|
|
47
|
-
await fs.mkdir(targetDirectory, { recursive: true });
|
|
48
|
-
await fs.writeFile(targetPath, testHTMLTemplate);
|
|
49
|
-
|
|
50
|
-
console.log(`${targetPath} written`);
|
|
51
|
-
}
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function rewritePackageJSON(projectRoot, newQunitxConfig, oldPackageJSON) {
|
|
56
|
-
let newPackageJSON = Object.assign(oldPackageJSON, { qunitx: newQunitxConfig });
|
|
57
|
-
|
|
58
|
-
await fs.writeFile(`${projectRoot}/package.json`, JSON.stringify(newPackageJSON, null, 2));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function writeTSConfigIfNeeded(projectRoot) {
|
|
62
|
-
let targetPath = `${projectRoot}/tsconfig.json`;
|
|
63
|
-
if (!(await pathExists(targetPath))) {
|
|
64
|
-
let tsConfigTemplateBuffer = await fs.readFile(`${__dirname}/../boilerplates/setup/tsconfig.json`);
|
|
65
|
-
|
|
66
|
-
await fs.writeFile(targetPath, tsConfigTemplateBuffer);
|
|
67
|
-
|
|
68
|
-
console.log(`${targetPath} written`);
|
|
69
|
-
}
|
|
70
|
-
}
|