poku 2.4.3 → 2.5.0-canary.61d28f3
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/lib/@types/poku.d.ts +2 -1
- package/lib/bin/enforce.js +52 -0
- package/lib/bin/index.js +21 -20
- package/lib/bin/watch.js +13 -20
- package/lib/builders/assert.d.ts +2 -2
- package/lib/builders/assert.js +31 -64
- package/lib/configs/poku.js +1 -1
- package/lib/modules/essentials/assert.d.ts +1 -1
- package/lib/modules/essentials/poku.d.ts +1 -1
- package/lib/modules/essentials/poku.js +6 -13
- package/lib/modules/helpers/create-service.d.ts +1 -1
- package/lib/modules/helpers/create-service.js +10 -12
- package/lib/modules/helpers/describe.d.ts +1 -1
- package/lib/modules/helpers/describe.js +13 -19
- package/lib/modules/helpers/each.js +2 -4
- package/lib/modules/helpers/env.js +4 -4
- package/lib/modules/helpers/exit.js +4 -8
- package/lib/modules/helpers/it/core.d.ts +1 -1
- package/lib/modules/helpers/it/core.js +10 -15
- package/lib/modules/helpers/it/todo.d.ts +1 -1
- package/lib/modules/helpers/it/todo.js +1 -3
- package/lib/modules/helpers/kill.js +2 -4
- package/lib/modules/helpers/list-files.js +7 -13
- package/lib/modules/helpers/skip.js +1 -2
- package/lib/modules/helpers/test.d.ts +1 -1
- package/lib/modules/helpers/wait-for.js +11 -22
- package/lib/parsers/assert.js +17 -30
- package/lib/parsers/find-file-from-stack.js +12 -12
- package/lib/parsers/get-arg.js +17 -22
- package/lib/parsers/get-runner.js +10 -15
- package/lib/parsers/get-runtime.d.ts +2 -2
- package/lib/parsers/get-runtime.js +6 -18
- package/lib/parsers/options.js +2 -3
- package/lib/parsers/output.js +5 -10
- package/lib/parsers/time.js +6 -6
- package/lib/parsers/to-dynamic-case.d.ts +1 -0
- package/lib/parsers/to-dynamic-case.js +13 -0
- package/lib/polyfills/fs.d.ts +1 -1
- package/lib/polyfills/jsonc.js +2 -4
- package/lib/polyfills/object.d.ts +12 -4
- package/lib/polyfills/object.js +20 -18
- package/lib/services/assert.js +13 -22
- package/lib/services/container.js +17 -29
- package/lib/services/each.js +3 -6
- package/lib/services/env.js +6 -9
- package/lib/services/format.d.ts +1 -0
- package/lib/services/format.js +19 -24
- package/lib/services/map-tests.js +9 -16
- package/lib/services/pid.js +6 -16
- package/lib/services/run-test-file.js +5 -6
- package/lib/services/run-tests.js +15 -12
- package/lib/services/watch.js +11 -18
- package/lib/services/write.d.ts +1 -1
- package/lib/services/write.js +1 -3
- package/package.json +10 -15
- /package/lib/polyfills/{cpus.d.ts → os.d.ts} +0 -0
- /package/lib/polyfills/{cpus.js → os.js} +0 -0
package/lib/@types/poku.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type DenoOptions = {
|
|
|
4
4
|
deny?: string[];
|
|
5
5
|
cjs?: boolean | string[];
|
|
6
6
|
};
|
|
7
|
+
export type Runtime = 'node' | 'bun' | 'deno';
|
|
7
8
|
export type Configs = {
|
|
8
9
|
/**
|
|
9
10
|
* By setting `true`, **Poku** won't exit the process and will return the exit code (`0` or `1`).
|
|
@@ -36,7 +37,7 @@ export type Configs = {
|
|
|
36
37
|
*
|
|
37
38
|
* @default 'node'
|
|
38
39
|
*/
|
|
39
|
-
platform?:
|
|
40
|
+
platform?: Runtime;
|
|
40
41
|
/**
|
|
41
42
|
* Stops the tests at the first failure.
|
|
42
43
|
*
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkFlags = void 0;
|
|
4
|
+
const node_process_1 = require("process");
|
|
5
|
+
const write_js_1 = require("../services/write.js");
|
|
6
|
+
const format_js_1 = require("../services/format.js");
|
|
7
|
+
const checkFlags = () => {
|
|
8
|
+
const allowedFlags = new Set([
|
|
9
|
+
'--bun',
|
|
10
|
+
'--concurrency',
|
|
11
|
+
'--config',
|
|
12
|
+
'--debug',
|
|
13
|
+
'--deno',
|
|
14
|
+
'--denoAllow',
|
|
15
|
+
'--denoCjs',
|
|
16
|
+
'--denoDeny',
|
|
17
|
+
'--enforce',
|
|
18
|
+
'--envFile',
|
|
19
|
+
'--exclude',
|
|
20
|
+
'--failFast',
|
|
21
|
+
'--filter',
|
|
22
|
+
'--killPid',
|
|
23
|
+
'--killPort',
|
|
24
|
+
'--killRange',
|
|
25
|
+
'--node',
|
|
26
|
+
'--parallel',
|
|
27
|
+
'--platform',
|
|
28
|
+
'--quiet',
|
|
29
|
+
'--watch',
|
|
30
|
+
'--watchInterval',
|
|
31
|
+
'-c',
|
|
32
|
+
'-d',
|
|
33
|
+
'-p',
|
|
34
|
+
'-q',
|
|
35
|
+
'-w',
|
|
36
|
+
'-x',
|
|
37
|
+
]);
|
|
38
|
+
const args = node_process_1.argv.slice(2);
|
|
39
|
+
const unrecognizedFlags = [];
|
|
40
|
+
for (const arg of args) {
|
|
41
|
+
const flagName = arg.split('=')[0];
|
|
42
|
+
if (!allowedFlags.has(flagName) && flagName.startsWith('-'))
|
|
43
|
+
unrecognizedFlags.push(flagName);
|
|
44
|
+
}
|
|
45
|
+
if (unrecognizedFlags.length > 0) {
|
|
46
|
+
write_js_1.Write.hr();
|
|
47
|
+
write_js_1.Write.log(`${(0, format_js_1.format)('Unrecognized flags:').bold()}\n\n${unrecognizedFlags.map((flag) => (0, format_js_1.format)(flag).fail()).join('\n')}`);
|
|
48
|
+
write_js_1.Write.hr();
|
|
49
|
+
(0, node_process_1.exit)(1);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.checkFlags = checkFlags;
|
package/lib/bin/index.js
CHANGED
|
@@ -18,15 +18,15 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
18
18
|
write_js_1.Write.log(VERSION);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
+
const enforce = (0, get_arg_js_1.hasArg)('enforce') || (0, get_arg_js_1.hasArg)('x', '-');
|
|
21
22
|
const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');
|
|
22
23
|
const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
|
|
23
24
|
const dirs = (() => {
|
|
24
25
|
var _a;
|
|
25
26
|
|
|
26
27
|
const includeArg = (0, get_arg_js_1.getArg)('include');
|
|
27
|
-
if (includeArg !== undefined)
|
|
28
|
+
if (includeArg !== undefined)
|
|
28
29
|
return includeArg.split(',');
|
|
29
|
-
}
|
|
30
30
|
return ((_a = (0, get_arg_js_1.getPaths)('-')) !== null && _a !== void 0 ? _a : ((defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
|
|
31
31
|
? Array.prototype.concat(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
|
|
32
32
|
: ['.']));
|
|
@@ -34,37 +34,35 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
34
34
|
const platform = (0, get_arg_js_1.getArg)('platform');
|
|
35
35
|
const filter = (_a = (0, get_arg_js_1.getArg)('filter')) !== null && _a !== void 0 ? _a : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.filter;
|
|
36
36
|
const exclude = (_b = (0, get_arg_js_1.getArg)('exclude')) !== null && _b !== void 0 ? _b : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.exclude;
|
|
37
|
-
const killPort = (0, get_arg_js_1.getArg)('
|
|
38
|
-
const killRange = (0, get_arg_js_1.getArg)('
|
|
39
|
-
const killPID = (0, get_arg_js_1.getArg)('
|
|
37
|
+
const killPort = (0, get_arg_js_1.getArg)('killport');
|
|
38
|
+
const killRange = (0, get_arg_js_1.getArg)('killrange');
|
|
39
|
+
const killPID = (0, get_arg_js_1.getArg)('killpid');
|
|
40
40
|
|
|
41
|
-
const denoAllow = (_c = (0, get_arg_js_1.argToArray)('
|
|
42
|
-
const denoDeny = (_e = (0, get_arg_js_1.argToArray)('
|
|
43
|
-
const denoCJS = ((_g = (0, get_arg_js_1.getArg)('
|
|
44
|
-
(0, get_arg_js_1.hasArg)('
|
|
41
|
+
const denoAllow = (_c = (0, get_arg_js_1.argToArray)('denoallow')) !== null && _c !== void 0 ? _c : (_d = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _d === void 0 ? void 0 : _d.allow;
|
|
42
|
+
const denoDeny = (_e = (0, get_arg_js_1.argToArray)('denodeny')) !== null && _e !== void 0 ? _e : (_f = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _f === void 0 ? void 0 : _f.deny;
|
|
43
|
+
const denoCJS = ((_g = (0, get_arg_js_1.getArg)('denocjs')) === null || _g === void 0 ? void 0 : _g.split(',').map((a) => a.trim()).filter((a) => a)) ||
|
|
44
|
+
(0, get_arg_js_1.hasArg)('denocjs') ||
|
|
45
45
|
((_h = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _h === void 0 ? void 0 : _h.cjs);
|
|
46
46
|
|
|
47
47
|
const parallel = (0, get_arg_js_1.hasArg)('parallel') || (0, get_arg_js_1.hasArg)('p', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel);
|
|
48
48
|
const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.quiet);
|
|
49
49
|
const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.debug);
|
|
50
|
-
const failFast = (0, get_arg_js_1.hasArg)('
|
|
50
|
+
const failFast = (0, get_arg_js_1.hasArg)('failfast') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.failFast);
|
|
51
51
|
const watchMode = (0, get_arg_js_1.hasArg)('watch') || (0, get_arg_js_1.hasArg)('w', '-');
|
|
52
|
-
const hasEnvFile = (0, get_arg_js_1.hasArg)('
|
|
52
|
+
const hasEnvFile = (0, get_arg_js_1.hasArg)('envfile');
|
|
53
53
|
const concurrency = (() => {
|
|
54
|
-
if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel)))
|
|
55
|
-
return
|
|
56
|
-
}
|
|
54
|
+
if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel)))
|
|
55
|
+
return;
|
|
57
56
|
const value = Number((0, get_arg_js_1.getArg)('concurrency'));
|
|
58
57
|
return Number.isNaN(value) ? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.concurrency : value;
|
|
59
58
|
})();
|
|
60
|
-
if (dirs.length === 1)
|
|
59
|
+
if (dirs.length === 1)
|
|
61
60
|
files_js_1.states.isSinglePath = true;
|
|
62
|
-
|
|
63
|
-
if ((0, get_arg_js_1.hasArg)('list-files')) {
|
|
61
|
+
if ((0, get_arg_js_1.hasArg)('listfiles')) {
|
|
64
62
|
const { listFiles } = require('../modules/helpers/list-files.js');
|
|
65
63
|
const files = [];
|
|
66
64
|
write_js_1.Write.hr();
|
|
67
|
-
for (const dir of dirs)
|
|
65
|
+
for (const dir of dirs)
|
|
68
66
|
files.push(...(await listFiles(dir, {
|
|
69
67
|
filter: typeof filter === 'string'
|
|
70
68
|
? new RegExp((0, list_files_js_1.escapeRegExp)(filter))
|
|
@@ -73,7 +71,6 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
73
71
|
? new RegExp((0, list_files_js_1.escapeRegExp)(exclude))
|
|
74
72
|
: exclude,
|
|
75
73
|
})));
|
|
76
|
-
}
|
|
77
74
|
write_js_1.Write.log(files
|
|
78
75
|
.sort()
|
|
79
76
|
.map((file) => `${(0, format_js_1.format)('-').dim()} ${file}`)
|
|
@@ -83,6 +80,10 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
83
80
|
write_js_1.Write.hr();
|
|
84
81
|
return;
|
|
85
82
|
}
|
|
83
|
+
if (enforce) {
|
|
84
|
+
const { checkFlags } = require('./enforce.js');
|
|
85
|
+
checkFlags();
|
|
86
|
+
}
|
|
86
87
|
const tasks = [];
|
|
87
88
|
|
|
88
89
|
if (killPort || ((_j = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _j === void 0 ? void 0 : _j.port)) {
|
|
@@ -106,7 +107,7 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
if (hasEnvFile || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile)) {
|
|
109
|
-
const envFilePath = (_r = (0, get_arg_js_1.getArg)('
|
|
110
|
+
const envFilePath = (_r = (0, get_arg_js_1.getArg)('envfile')) !== null && _r !== void 0 ? _r : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile;
|
|
110
111
|
tasks.push((0, env_js_1.envFile)(envFilePath));
|
|
111
112
|
}
|
|
112
113
|
const options = {
|
package/lib/bin/watch.js
CHANGED
|
@@ -12,12 +12,12 @@ const node_process_1 = __importDefault(require("process"));
|
|
|
12
12
|
const format_js_1 = require("../services/format.js");
|
|
13
13
|
const get_arg_js_1 = require("../parsers/get-arg.js");
|
|
14
14
|
const files_js_1 = require("../configs/files.js");
|
|
15
|
-
const
|
|
15
|
+
const os_js_1 = require("../polyfills/os.js");
|
|
16
16
|
const startWatch = async (dirs, options) => {
|
|
17
17
|
let isRunning = false;
|
|
18
18
|
const watchers = new Set();
|
|
19
19
|
const executing = new Set();
|
|
20
|
-
const interval = Number((0, get_arg_js_1.getArg)('
|
|
20
|
+
const interval = Number((0, get_arg_js_1.getArg)('watchinterval')) || 1500;
|
|
21
21
|
const setIsRunning = (value) => {
|
|
22
22
|
isRunning = value;
|
|
23
23
|
};
|
|
@@ -26,13 +26,11 @@ const startWatch = async (dirs, options) => {
|
|
|
26
26
|
files_js_1.fileResults.fail.clear();
|
|
27
27
|
};
|
|
28
28
|
const listenStdin = async (input) => {
|
|
29
|
-
if (isRunning || executing.size > 0)
|
|
29
|
+
if (isRunning || executing.size > 0)
|
|
30
30
|
return;
|
|
31
|
-
}
|
|
32
31
|
if (String(input).trim() === 'rs') {
|
|
33
|
-
for (const watcher of watchers)
|
|
32
|
+
for (const watcher of watchers)
|
|
34
33
|
watcher.stop();
|
|
35
|
-
}
|
|
36
34
|
watchers.clear();
|
|
37
35
|
resultsClear();
|
|
38
36
|
await (0, poku_js_1.poku)(dirs, options);
|
|
@@ -47,19 +45,17 @@ const startWatch = async (dirs, options) => {
|
|
|
47
45
|
var _a;
|
|
48
46
|
if (event === 'change') {
|
|
49
47
|
const filePath = (0, map_tests_js_1.normalizePath)(file);
|
|
50
|
-
if (executing.has(filePath) || isRunning || executing.size > 0)
|
|
48
|
+
if (executing.has(filePath) || isRunning || executing.size > 0)
|
|
51
49
|
return;
|
|
52
|
-
}
|
|
53
50
|
setIsRunning(true);
|
|
54
51
|
executing.add(filePath);
|
|
55
52
|
resultsClear();
|
|
56
53
|
const tests = mappedTests.get(filePath);
|
|
57
|
-
if (!tests)
|
|
54
|
+
if (!tests)
|
|
58
55
|
return;
|
|
59
|
-
}
|
|
60
56
|
await (0, poku_js_1.poku)(Array.from(tests), {
|
|
61
57
|
...options,
|
|
62
|
-
concurrency: (_a = options.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0,
|
|
58
|
+
concurrency: (_a = options.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0, os_js_1.availableParallelism)() / 2), 1),
|
|
63
59
|
});
|
|
64
60
|
setTimeout(() => {
|
|
65
61
|
executing.delete(filePath);
|
|
@@ -72,25 +68,22 @@ const startWatch = async (dirs, options) => {
|
|
|
72
68
|
for (const dir of dirs) {
|
|
73
69
|
const currentWatcher = (0, watch_js_1.watch)(dir, (file, event) => {
|
|
74
70
|
if (event === 'change') {
|
|
75
|
-
if (executing.has(file) || isRunning || executing.size > 0)
|
|
71
|
+
if (executing.has(file) || isRunning || executing.size > 0)
|
|
76
72
|
return;
|
|
77
|
-
}
|
|
78
73
|
setIsRunning(true);
|
|
79
74
|
executing.add(file);
|
|
80
75
|
resultsClear();
|
|
81
|
-
(0, poku_js_1.poku)(file, options).then(() => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}, interval);
|
|
86
|
-
});
|
|
76
|
+
(0, poku_js_1.poku)(file, options).then(() => setTimeout(() => {
|
|
77
|
+
executing.delete(file);
|
|
78
|
+
setIsRunning(false);
|
|
79
|
+
}, interval));
|
|
87
80
|
}
|
|
88
81
|
});
|
|
89
82
|
currentWatcher.then((watcher) => watchers.add(watcher));
|
|
90
83
|
}
|
|
91
84
|
write_js_1.Write.hr();
|
|
92
85
|
write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
|
|
93
|
-
node_process_1.default.stdin.setEncoding('
|
|
86
|
+
node_process_1.default.stdin.setEncoding('utf8');
|
|
94
87
|
node_process_1.default.stdin.on('data', listenStdin);
|
|
95
88
|
};
|
|
96
89
|
exports.startWatch = startWatch;
|
package/lib/builders/assert.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProcessAssertionOptions } from '../@types/assert.js';
|
|
2
|
-
import type assert from
|
|
3
|
-
import type { AssertPredicate } from
|
|
2
|
+
import type assert from "assert";
|
|
3
|
+
import type { AssertPredicate } from "assert";
|
|
4
4
|
export declare const createAssert: (nodeAssert: typeof assert) => ((value: unknown, message?: ProcessAssertionOptions["message"]) => void) & {
|
|
5
5
|
ok: (value: unknown, message?: ProcessAssertionOptions["message"]) => void;
|
|
6
6
|
equal: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
|
package/lib/builders/assert.js
CHANGED
|
@@ -4,59 +4,33 @@ exports.createAssert = void 0;
|
|
|
4
4
|
const get_runtime_js_1 = require("../parsers/get-runtime.js");
|
|
5
5
|
const assert_js_1 = require("../services/assert.js");
|
|
6
6
|
const createAssert = (nodeAssert) => {
|
|
7
|
-
const ok = (value, message) => {
|
|
8
|
-
(0, assert_js_1.processAssert)(() => {
|
|
9
|
-
nodeAssert.ok(value);
|
|
10
|
-
}, { message });
|
|
11
|
-
};
|
|
7
|
+
const ok = (value, message) => (0, assert_js_1.processAssert)(() => nodeAssert.ok(value), { message });
|
|
12
8
|
const equal = (actual, expected, message) => {
|
|
13
|
-
(0, assert_js_1.processAssert)(() => {
|
|
14
|
-
nodeAssert.equal(actual, expected);
|
|
15
|
-
}, { message });
|
|
16
|
-
};
|
|
17
|
-
const deepEqual = (actual, expected, message) => {
|
|
18
|
-
(0, assert_js_1.processAssert)(() => nodeAssert.deepEqual(actual, expected), { message });
|
|
19
|
-
};
|
|
20
|
-
const strictEqual = (actual, expected, message) => {
|
|
21
|
-
(0, assert_js_1.processAssert)(() => nodeAssert.strictEqual(actual, expected), { message });
|
|
22
|
-
};
|
|
23
|
-
const deepStrictEqual = (actual, expected, message) => {
|
|
24
|
-
(0, assert_js_1.processAssert)(() => nodeAssert.deepStrictEqual(actual, expected), {
|
|
25
|
-
message,
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
const notEqual = (actual, expected, message) => {
|
|
29
|
-
(0, assert_js_1.processAssert)(() => nodeAssert.notEqual(actual, expected), {
|
|
30
|
-
message,
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
const notDeepEqual = (actual, expected, message) => {
|
|
34
|
-
(0, assert_js_1.processAssert)(() => nodeAssert.notDeepEqual(actual, expected), { message });
|
|
35
|
-
};
|
|
36
|
-
const notStrictEqual = (actual, expected, message) => {
|
|
37
|
-
(0, assert_js_1.processAssert)(() => nodeAssert.notStrictEqual(actual, expected), {
|
|
38
|
-
message,
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
const notDeepStrictEqual = (actual, expected, message) => {
|
|
42
|
-
(0, assert_js_1.processAssert)(() => nodeAssert.notDeepStrictEqual(actual, expected), {
|
|
43
|
-
message,
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
const ifError = (value, message) => {
|
|
47
|
-
(0, assert_js_1.processAssert)(() => {
|
|
48
|
-
nodeAssert.ifError(value);
|
|
49
|
-
}, {
|
|
50
|
-
message,
|
|
51
|
-
defaultMessage: 'Expected no error, but received an error',
|
|
52
|
-
hideDiff: true,
|
|
53
|
-
throw: true,
|
|
54
|
-
});
|
|
9
|
+
(0, assert_js_1.processAssert)(() => nodeAssert.equal(actual, expected), { message });
|
|
55
10
|
};
|
|
11
|
+
const deepEqual = (actual, expected, message) => (0, assert_js_1.processAssert)(() => nodeAssert.deepEqual(actual, expected), { message });
|
|
12
|
+
const strictEqual = (actual, expected, message) => (0, assert_js_1.processAssert)(() => nodeAssert.strictEqual(actual, expected), { message });
|
|
13
|
+
const deepStrictEqual = (actual, expected, message) => (0, assert_js_1.processAssert)(() => nodeAssert.deepStrictEqual(actual, expected), {
|
|
14
|
+
message,
|
|
15
|
+
});
|
|
16
|
+
const notEqual = (actual, expected, message) => (0, assert_js_1.processAssert)(() => nodeAssert.notEqual(actual, expected), {
|
|
17
|
+
message,
|
|
18
|
+
});
|
|
19
|
+
const notDeepEqual = (actual, expected, message) => (0, assert_js_1.processAssert)(() => nodeAssert.notDeepEqual(actual, expected), { message });
|
|
20
|
+
const notStrictEqual = (actual, expected, message) => (0, assert_js_1.processAssert)(() => nodeAssert.notStrictEqual(actual, expected), {
|
|
21
|
+
message,
|
|
22
|
+
});
|
|
23
|
+
const notDeepStrictEqual = (actual, expected, message) => (0, assert_js_1.processAssert)(() => nodeAssert.notDeepStrictEqual(actual, expected), {
|
|
24
|
+
message,
|
|
25
|
+
});
|
|
26
|
+
const ifError = (value, message) => (0, assert_js_1.processAssert)(() => nodeAssert.ifError(value), {
|
|
27
|
+
message,
|
|
28
|
+
defaultMessage: 'Expected no error, but received an error',
|
|
29
|
+
hideDiff: true,
|
|
30
|
+
throw: true,
|
|
31
|
+
});
|
|
56
32
|
const fail = (message) => {
|
|
57
|
-
(0, assert_js_1.processAssert)(() => {
|
|
58
|
-
nodeAssert.fail(message);
|
|
59
|
-
}, {
|
|
33
|
+
(0, assert_js_1.processAssert)(() => nodeAssert.fail(message), {
|
|
60
34
|
message,
|
|
61
35
|
defaultMessage: 'Test failed intentionally',
|
|
62
36
|
hideDiff: true,
|
|
@@ -67,9 +41,8 @@ const createAssert = (nodeAssert) => {
|
|
|
67
41
|
(0, assert_js_1.processAssert)(() => {
|
|
68
42
|
if (typeof errorOrMessage === 'function' ||
|
|
69
43
|
errorOrMessage instanceof RegExp ||
|
|
70
|
-
typeof errorOrMessage === 'object')
|
|
44
|
+
typeof errorOrMessage === 'object')
|
|
71
45
|
nodeAssert.doesNotThrow(block, errorOrMessage, message);
|
|
72
|
-
}
|
|
73
46
|
else {
|
|
74
47
|
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;
|
|
75
48
|
nodeAssert.doesNotThrow(block, msg);
|
|
@@ -84,13 +57,12 @@ const createAssert = (nodeAssert) => {
|
|
|
84
57
|
function throws(block, errorOrMessage, message) {
|
|
85
58
|
if (typeof errorOrMessage === 'function' ||
|
|
86
59
|
errorOrMessage instanceof RegExp ||
|
|
87
|
-
typeof errorOrMessage === 'object')
|
|
60
|
+
typeof errorOrMessage === 'object')
|
|
88
61
|
(0, assert_js_1.processAssert)(() => nodeAssert.throws(block, errorOrMessage), {
|
|
89
62
|
message,
|
|
90
63
|
defaultMessage: 'Expected function to throw',
|
|
91
64
|
hideDiff: true,
|
|
92
65
|
});
|
|
93
|
-
}
|
|
94
66
|
else {
|
|
95
67
|
const msg = typeof errorOrMessage !== 'undefined' ? errorOrMessage : message;
|
|
96
68
|
(0, assert_js_1.processAssert)(() => nodeAssert.throws(block, message), {
|
|
@@ -104,9 +76,8 @@ const createAssert = (nodeAssert) => {
|
|
|
104
76
|
await (0, assert_js_1.processAsyncAssert)(async () => {
|
|
105
77
|
if (typeof errorOrMessage === 'function' ||
|
|
106
78
|
errorOrMessage instanceof RegExp ||
|
|
107
|
-
typeof errorOrMessage === 'object')
|
|
79
|
+
typeof errorOrMessage === 'object')
|
|
108
80
|
await nodeAssert.rejects(block, errorOrMessage, message);
|
|
109
|
-
}
|
|
110
81
|
else {
|
|
111
82
|
const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;
|
|
112
83
|
await nodeAssert.rejects(block, msg);
|
|
@@ -122,12 +93,10 @@ const createAssert = (nodeAssert) => {
|
|
|
122
93
|
await (0, assert_js_1.processAsyncAssert)(async () => {
|
|
123
94
|
if (typeof errorOrMessage === 'function' ||
|
|
124
95
|
errorOrMessage instanceof RegExp ||
|
|
125
|
-
typeof errorOrMessage === 'object')
|
|
96
|
+
typeof errorOrMessage === 'object')
|
|
126
97
|
await nodeAssert.doesNotReject(block, errorOrMessage, message);
|
|
127
|
-
|
|
128
|
-
else {
|
|
98
|
+
else
|
|
129
99
|
await nodeAssert.doesNotReject(block, message);
|
|
130
|
-
}
|
|
131
100
|
}, {
|
|
132
101
|
message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
|
|
133
102
|
defaultMessage: 'Got unwanted rejection',
|
|
@@ -137,9 +106,8 @@ const createAssert = (nodeAssert) => {
|
|
|
137
106
|
}
|
|
138
107
|
const match = (value, regExp, message) => {
|
|
139
108
|
|
|
140
|
-
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12)
|
|
109
|
+
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12)
|
|
141
110
|
throw new Error('match is available from Node.js 12 or higher');
|
|
142
|
-
}
|
|
143
111
|
(0, assert_js_1.processAssert)(() => nodeAssert === null || nodeAssert === void 0 ? void 0 : nodeAssert.match(value, regExp), {
|
|
144
112
|
message,
|
|
145
113
|
actual: 'Value',
|
|
@@ -149,9 +117,8 @@ const createAssert = (nodeAssert) => {
|
|
|
149
117
|
};
|
|
150
118
|
const doesNotMatch = (value, regExp, message) => {
|
|
151
119
|
|
|
152
|
-
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12)
|
|
120
|
+
if (typeof get_runtime_js_1.nodeVersion === 'number' && get_runtime_js_1.nodeVersion < 12)
|
|
153
121
|
throw new Error('doesNotMatch is available from Node.js 12 or higher');
|
|
154
|
-
}
|
|
155
122
|
(0, assert_js_1.processAssert)(() => nodeAssert.doesNotMatch(value, regExp), {
|
|
156
123
|
message,
|
|
157
124
|
actual: 'Value',
|
package/lib/configs/poku.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import nodeAssert from
|
|
1
|
+
import nodeAssert from "assert";
|
|
2
2
|
export declare const assert: ((value: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void) & {
|
|
3
3
|
ok: (value: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
|
|
4
4
|
equal: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Code } from '../../@types/code.js';
|
|
2
2
|
import type { Configs } from '../../@types/poku.js';
|
|
3
|
-
export declare const onSigint: () =>
|
|
3
|
+
export declare const onSigint: () => boolean;
|
|
4
4
|
export declare function poku(targetPaths: string | string[], configs: Configs & {
|
|
5
5
|
noExit: true;
|
|
6
6
|
}): Promise<Code>;
|
|
@@ -13,9 +13,7 @@ const format_js_1 = require("../../services/format.js");
|
|
|
13
13
|
const output_js_1 = require("../../parsers/output.js");
|
|
14
14
|
const files_js_1 = require("../../configs/files.js");
|
|
15
15
|
|
|
16
|
-
const onSigint = () =>
|
|
17
|
-
node_process_1.default.stdout.write('\u001B[?25h');
|
|
18
|
-
};
|
|
16
|
+
const onSigint = () => node_process_1.default.stdout.write('\u001B[?25h');
|
|
19
17
|
exports.onSigint = onSigint;
|
|
20
18
|
node_process_1.default.once('SIGINT', exports.onSigint);
|
|
21
19
|
async function poku(targetPaths, configs) {
|
|
@@ -30,14 +28,12 @@ async function poku(targetPaths, configs) {
|
|
|
30
28
|
const result = await (0, run_tests_js_1.runTests)(dir, configs);
|
|
31
29
|
if (!result) {
|
|
32
30
|
code = 1;
|
|
33
|
-
if (configs === null || configs === void 0 ? void 0 : configs.failFast)
|
|
31
|
+
if (configs === null || configs === void 0 ? void 0 : configs.failFast)
|
|
34
32
|
break;
|
|
35
|
-
}
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
if (configs === null || configs === void 0 ? void 0 : configs.noExit)
|
|
35
|
+
if (configs === null || configs === void 0 ? void 0 : configs.noExit)
|
|
39
36
|
return code;
|
|
40
|
-
}
|
|
41
37
|
const end = node_process_1.default.hrtime(start);
|
|
42
38
|
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
|
|
43
39
|
files_js_1.finalResults.time = total;
|
|
@@ -53,15 +49,13 @@ async function poku(targetPaths, configs) {
|
|
|
53
49
|
try {
|
|
54
50
|
const promises = dirs.map(async (dir) => {
|
|
55
51
|
const result = await (0, run_tests_js_1.runTestsParallel)(dir, configs);
|
|
56
|
-
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast))
|
|
52
|
+
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast))
|
|
57
53
|
throw new Error('quiet');
|
|
58
|
-
}
|
|
59
54
|
return result;
|
|
60
55
|
});
|
|
61
56
|
const concurrency = await Promise.all(promises);
|
|
62
|
-
if (concurrency.some((result) => !result))
|
|
57
|
+
if (concurrency.some((result) => !result))
|
|
63
58
|
code = 1;
|
|
64
|
-
}
|
|
65
59
|
}
|
|
66
60
|
catch (_a) {
|
|
67
61
|
}
|
|
@@ -71,8 +65,7 @@ async function poku(targetPaths, configs) {
|
|
|
71
65
|
files_js_1.finalResults.time = total;
|
|
72
66
|
}
|
|
73
67
|
showLogs && (0, format_js_1.showTestResults)();
|
|
74
|
-
if (configs === null || configs === void 0 ? void 0 : configs.noExit)
|
|
68
|
+
if (configs === null || configs === void 0 ? void 0 : configs.noExit)
|
|
75
69
|
return code;
|
|
76
|
-
}
|
|
77
70
|
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
|
|
78
71
|
}
|
|
@@ -9,7 +9,7 @@ export declare const startService: (file: string, options?: StartServiceOptions)
|
|
|
9
9
|
*
|
|
10
10
|
* ---
|
|
11
11
|
*
|
|
12
|
-
* By default
|
|
12
|
+
* By default it uses **npm**, but you can costumize it using the `runner` option.
|
|
13
13
|
*/
|
|
14
14
|
export declare const startScript: (script: string, options?: StartScriptOptions) => Promise<{
|
|
15
15
|
end: End;
|
|
@@ -25,6 +25,8 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
25
25
|
windowsHide: get_runner_js_1.isWindows,
|
|
26
26
|
});
|
|
27
27
|
const PID = service.pid;
|
|
28
|
+
service.stdout.setEncoding('utf8');
|
|
29
|
+
service.stderr.setEncoding('utf8');
|
|
28
30
|
let portBackup;
|
|
29
31
|
const end = (port) => new Promise((resolve) => {
|
|
30
32
|
try {
|
|
@@ -34,12 +36,10 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
36
38
|
if (['bun', 'deno'].includes(runtime) ||
|
|
37
|
-
['bun', 'deno'].includes(String(options === null || options === void 0 ? void 0 : options.runner)))
|
|
39
|
+
['bun', 'deno'].includes(String(options === null || options === void 0 ? void 0 : options.runner)))
|
|
38
40
|
node_process_1.default.kill(PID);
|
|
39
|
-
|
|
40
|
-
else {
|
|
41
|
+
else
|
|
41
42
|
node_process_1.default.kill(-PID, 'SIGKILL');
|
|
42
|
-
}
|
|
43
43
|
if (port && ['bun', 'deno'].includes(runtime)) {
|
|
44
44
|
setTimeout(async () => {
|
|
45
45
|
await kill_js_1.kill.port(port);
|
|
@@ -89,9 +89,8 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
89
89
|
reject(`Service failed to start: ${err}`);
|
|
90
90
|
});
|
|
91
91
|
service.on('close', (code) => {
|
|
92
|
-
if (code !== 0)
|
|
92
|
+
if (code !== 0)
|
|
93
93
|
reject(`Service exited with code ${code}`);
|
|
94
|
-
}
|
|
95
94
|
});
|
|
96
95
|
const timeout = setTimeout(() => {
|
|
97
96
|
if (!isResolved) {
|
|
@@ -99,7 +98,7 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
99
98
|
reject(`createService: Timeout\nFile: ${file}`);
|
|
100
99
|
}
|
|
101
100
|
}, (options === null || options === void 0 ? void 0 : options.timeout) || 60000);
|
|
102
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'number')
|
|
101
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.startAfter) === 'number')
|
|
103
102
|
setTimeout(() => {
|
|
104
103
|
if (!isResolved) {
|
|
105
104
|
resolve({ end });
|
|
@@ -107,7 +106,6 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
107
106
|
isResolved = true;
|
|
108
107
|
}
|
|
109
108
|
}, options.startAfter);
|
|
110
|
-
}
|
|
111
109
|
}
|
|
112
110
|
catch (_a) { }
|
|
113
111
|
});
|
|
@@ -125,10 +123,11 @@ exports.startService = startService;
|
|
|
125
123
|
*
|
|
126
124
|
* ---
|
|
127
125
|
*
|
|
128
|
-
* By default
|
|
126
|
+
* By default it uses **npm**, but you can costumize it using the `runner` option.
|
|
129
127
|
*/
|
|
130
128
|
const startScript = async (script, options) => {
|
|
131
|
-
|
|
129
|
+
var _a;
|
|
130
|
+
const runner = (_a = options === null || options === void 0 ? void 0 : options.runner) !== null && _a !== void 0 ? _a : 'npm';
|
|
132
131
|
const runtimeOptions = (0, get_runner_js_1.scriptRunner)(runner);
|
|
133
132
|
const runtime = runtimeOptions.shift();
|
|
134
133
|
const runtimeArgs = [...runtimeOptions, script];
|
|
@@ -139,7 +138,6 @@ const startScript = async (script, options) => {
|
|
|
139
138
|
};
|
|
140
139
|
exports.startScript = startScript;
|
|
141
140
|
node_process_1.default.once('SIGINT', async () => {
|
|
142
|
-
for (const { end, port } of runningProcesses.values())
|
|
141
|
+
for (const { end, port } of runningProcesses.values())
|
|
143
142
|
await end(port);
|
|
144
|
-
}
|
|
145
143
|
});
|
|
@@ -5,6 +5,6 @@ declare function describeCore(cb: () => Promise<unknown>): Promise<void>;
|
|
|
5
5
|
declare function describeCore(cb: () => unknown): unknown;
|
|
6
6
|
declare function describeCore(title: string, options?: DescribeOptions): void;
|
|
7
7
|
export declare const describe: typeof describeCore & {
|
|
8
|
-
todo: (message: string, _cb?: () => unknown) =>
|
|
8
|
+
todo: (message: string, _cb?: () => unknown) => boolean;
|
|
9
9
|
};
|
|
10
10
|
export {};
|
|
@@ -14,12 +14,10 @@ async function describeCore(arg1, arg2) {
|
|
|
14
14
|
const FILE = node_process_1.env.FILE;
|
|
15
15
|
if (typeof arg1 === 'string') {
|
|
16
16
|
title = arg1;
|
|
17
|
-
if (typeof arg2 === 'function')
|
|
17
|
+
if (typeof arg2 === 'function')
|
|
18
18
|
cb = arg2;
|
|
19
|
-
|
|
20
|
-
else {
|
|
19
|
+
else
|
|
21
20
|
options = arg2;
|
|
22
|
-
}
|
|
23
21
|
}
|
|
24
22
|
else if (typeof arg1 === 'function') {
|
|
25
23
|
cb = arg1;
|
|
@@ -27,30 +25,26 @@ async function describeCore(arg1, arg2) {
|
|
|
27
25
|
}
|
|
28
26
|
if (title) {
|
|
29
27
|
indentation_js_1.indentation.hasDescribe = true;
|
|
30
|
-
const { background, icon } = options
|
|
31
|
-
const message = `${cb ? (0, format_js_1.format)('◌').dim() : icon
|
|
28
|
+
const { background, icon } = options !== null && options !== void 0 ? options : {};
|
|
29
|
+
const message = `${cb ? (0, format_js_1.format)('◌').dim() : (icon !== null && icon !== void 0 ? icon : '☰')} ${cb ? (0, format_js_1.format)(isPoku ? `${title} › ${(0, format_js_1.format)(`${FILE}`).italic().gray()}` : title).dim() : (0, format_js_1.format)(title).bold()}`;
|
|
32
30
|
const noBackground = !background;
|
|
33
|
-
if (noBackground)
|
|
31
|
+
if (noBackground)
|
|
34
32
|
write_js_1.Write.log((0, format_js_1.format)(message).bold());
|
|
35
|
-
|
|
36
|
-
else {
|
|
33
|
+
else
|
|
37
34
|
write_js_1.Write.log((0, format_js_1.format)(` ${message} `).bg(typeof background === 'string' ? background : 'grey'));
|
|
38
|
-
}
|
|
39
35
|
}
|
|
40
|
-
if (typeof cb !== 'function')
|
|
36
|
+
if (typeof cb !== 'function')
|
|
41
37
|
return;
|
|
42
|
-
}
|
|
43
38
|
const start = (0, node_process_1.hrtime)();
|
|
44
39
|
const resultCb = cb();
|
|
45
|
-
if (resultCb instanceof Promise)
|
|
40
|
+
if (resultCb instanceof Promise)
|
|
46
41
|
await resultCb;
|
|
47
|
-
}
|
|
48
42
|
const end = (0, node_process_1.hrtime)(start);
|
|
49
|
-
if (title)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
43
|
+
if (!title)
|
|
44
|
+
return;
|
|
45
|
+
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
|
|
46
|
+
indentation_js_1.indentation.hasDescribe = false;
|
|
47
|
+
write_js_1.Write.log(`${(0, format_js_1.format)(`● ${title}`).success().bold()} ${(0, format_js_1.format)(`› ${total}ms`).success().dim()}`);
|
|
54
48
|
}
|
|
55
49
|
exports.describe = Object.assign(describeCore, {
|
|
56
50
|
todo: todo_js_1.todo,
|