poku 2.5.0 → 2.5.1-canary.f5ac8b7
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 +1 -2
- package/lib/bin/index.js +5 -9
- package/lib/bin/watch.js +11 -18
- package/lib/builders/assert.js +31 -64
- 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 +8 -12
- package/lib/modules/helpers/describe.d.ts +2 -1
- package/lib/modules/helpers/describe.js +15 -19
- package/lib/modules/helpers/each.js +2 -4
- package/lib/modules/helpers/env.js +1 -2
- package/lib/modules/helpers/exit.js +5 -9
- package/lib/modules/helpers/it/core.d.ts +2 -1
- package/lib/modules/helpers/it/core.js +12 -15
- package/lib/modules/helpers/it/skip.d.ts +1 -0
- package/lib/modules/helpers/it/skip.js +8 -0
- 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 +2 -1
- package/lib/modules/helpers/wait-for.js +10 -21
- package/lib/parsers/assert.js +17 -30
- package/lib/parsers/find-file-from-stack.js +12 -12
- package/lib/parsers/get-arg.js +12 -19
- 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 +1 -2
- package/lib/parsers/output.js +11 -14
- package/lib/parsers/time.js +6 -6
- package/lib/parsers/to-dynamic-case.js +4 -9
- 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 +15 -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 +17 -23
- package/lib/services/map-tests.js +7 -14
- package/lib/services/pid.js +6 -16
- package/lib/services/run-test-file.js +3 -6
- package/lib/services/run-tests.js +4 -6
- 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 +4 -4
- /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
|
*
|
package/lib/bin/enforce.js
CHANGED
|
@@ -39,9 +39,8 @@ const checkFlags = () => {
|
|
|
39
39
|
const unrecognizedFlags = [];
|
|
40
40
|
for (const arg of args) {
|
|
41
41
|
const flagName = arg.split('=')[0];
|
|
42
|
-
if (!allowedFlags.has(flagName) && flagName.startsWith('-'))
|
|
42
|
+
if (!allowedFlags.has(flagName) && flagName.startsWith('-'))
|
|
43
43
|
unrecognizedFlags.push(flagName);
|
|
44
|
-
}
|
|
45
44
|
}
|
|
46
45
|
if (unrecognizedFlags.length > 0) {
|
|
47
46
|
write_js_1.Write.hr();
|
package/lib/bin/index.js
CHANGED
|
@@ -25,9 +25,8 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
25
25
|
var _a;
|
|
26
26
|
|
|
27
27
|
const includeArg = (0, get_arg_js_1.getArg)('include');
|
|
28
|
-
if (includeArg !== undefined)
|
|
28
|
+
if (includeArg !== undefined)
|
|
29
29
|
return includeArg.split(',');
|
|
30
|
-
}
|
|
31
30
|
return ((_a = (0, get_arg_js_1.getPaths)('-')) !== null && _a !== void 0 ? _a : ((defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
|
|
32
31
|
? Array.prototype.concat(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
|
|
33
32
|
: ['.']));
|
|
@@ -52,20 +51,18 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
52
51
|
const watchMode = (0, get_arg_js_1.hasArg)('watch') || (0, get_arg_js_1.hasArg)('w', '-');
|
|
53
52
|
const hasEnvFile = (0, get_arg_js_1.hasArg)('envfile');
|
|
54
53
|
const concurrency = (() => {
|
|
55
|
-
if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel)))
|
|
56
|
-
return
|
|
57
|
-
}
|
|
54
|
+
if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel)))
|
|
55
|
+
return;
|
|
58
56
|
const value = Number((0, get_arg_js_1.getArg)('concurrency'));
|
|
59
57
|
return Number.isNaN(value) ? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.concurrency : value;
|
|
60
58
|
})();
|
|
61
|
-
if (dirs.length === 1)
|
|
59
|
+
if (dirs.length === 1)
|
|
62
60
|
files_js_1.states.isSinglePath = true;
|
|
63
|
-
}
|
|
64
61
|
if ((0, get_arg_js_1.hasArg)('listfiles')) {
|
|
65
62
|
const { listFiles } = require('../modules/helpers/list-files.js');
|
|
66
63
|
const files = [];
|
|
67
64
|
write_js_1.Write.hr();
|
|
68
|
-
for (const dir of dirs)
|
|
65
|
+
for (const dir of dirs)
|
|
69
66
|
files.push(...(await listFiles(dir, {
|
|
70
67
|
filter: typeof filter === 'string'
|
|
71
68
|
? new RegExp((0, list_files_js_1.escapeRegExp)(filter))
|
|
@@ -74,7 +71,6 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
74
71
|
? new RegExp((0, list_files_js_1.escapeRegExp)(exclude))
|
|
75
72
|
: exclude,
|
|
76
73
|
})));
|
|
77
|
-
}
|
|
78
74
|
write_js_1.Write.log(files
|
|
79
75
|
.sort()
|
|
80
76
|
.map((file) => `${(0, format_js_1.format)('-').dim()} ${file}`)
|
package/lib/bin/watch.js
CHANGED
|
@@ -12,7 +12,7 @@ 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();
|
|
@@ -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,18 +68,15 @@ 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));
|
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',
|
|
@@ -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;
|
|
@@ -36,12 +36,10 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
if (['bun', 'deno'].includes(runtime) ||
|
|
39
|
-
['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)))
|
|
40
40
|
node_process_1.default.kill(PID);
|
|
41
|
-
|
|
42
|
-
else {
|
|
41
|
+
else
|
|
43
42
|
node_process_1.default.kill(-PID, 'SIGKILL');
|
|
44
|
-
}
|
|
45
43
|
if (port && ['bun', 'deno'].includes(runtime)) {
|
|
46
44
|
setTimeout(async () => {
|
|
47
45
|
await kill_js_1.kill.port(port);
|
|
@@ -91,9 +89,8 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
91
89
|
reject(`Service failed to start: ${err}`);
|
|
92
90
|
});
|
|
93
91
|
service.on('close', (code) => {
|
|
94
|
-
if (code !== 0)
|
|
92
|
+
if (code !== 0)
|
|
95
93
|
reject(`Service exited with code ${code}`);
|
|
96
|
-
}
|
|
97
94
|
});
|
|
98
95
|
const timeout = setTimeout(() => {
|
|
99
96
|
if (!isResolved) {
|
|
@@ -101,7 +98,7 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
101
98
|
reject(`createService: Timeout\nFile: ${file}`);
|
|
102
99
|
}
|
|
103
100
|
}, (options === null || options === void 0 ? void 0 : options.timeout) || 60000);
|
|
104
|
-
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')
|
|
105
102
|
setTimeout(() => {
|
|
106
103
|
if (!isResolved) {
|
|
107
104
|
resolve({ end });
|
|
@@ -109,7 +106,6 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
|
|
|
109
106
|
isResolved = true;
|
|
110
107
|
}
|
|
111
108
|
}, options.startAfter);
|
|
112
|
-
}
|
|
113
109
|
}
|
|
114
110
|
catch (_a) { }
|
|
115
111
|
});
|
|
@@ -127,10 +123,11 @@ exports.startService = startService;
|
|
|
127
123
|
*
|
|
128
124
|
* ---
|
|
129
125
|
*
|
|
130
|
-
* By default
|
|
126
|
+
* By default it uses **npm**, but you can costumize it using the `runner` option.
|
|
131
127
|
*/
|
|
132
128
|
const startScript = async (script, options) => {
|
|
133
|
-
|
|
129
|
+
var _a;
|
|
130
|
+
const runner = (_a = options === null || options === void 0 ? void 0 : options.runner) !== null && _a !== void 0 ? _a : 'npm';
|
|
134
131
|
const runtimeOptions = (0, get_runner_js_1.scriptRunner)(runner);
|
|
135
132
|
const runtime = runtimeOptions.shift();
|
|
136
133
|
const runtimeArgs = [...runtimeOptions, script];
|
|
@@ -141,7 +138,6 @@ const startScript = async (script, options) => {
|
|
|
141
138
|
};
|
|
142
139
|
exports.startScript = startScript;
|
|
143
140
|
node_process_1.default.once('SIGINT', async () => {
|
|
144
|
-
for (const { end, port } of runningProcesses.values())
|
|
141
|
+
for (const { end, port } of runningProcesses.values())
|
|
145
142
|
await end(port);
|
|
146
|
-
}
|
|
147
143
|
});
|
|
@@ -5,6 +5,7 @@ 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
|
+
skip: (message: string, _cb?: () => unknown) => boolean;
|
|
9
10
|
};
|
|
10
11
|
export {};
|
|
@@ -6,6 +6,7 @@ const format_js_1 = require("../../services/format.js");
|
|
|
6
6
|
const write_js_1 = require("../../services/write.js");
|
|
7
7
|
const indentation_js_1 = require("../../configs/indentation.js");
|
|
8
8
|
const todo_js_1 = require("./it/todo.js");
|
|
9
|
+
const skip_js_1 = require("./it/skip.js");
|
|
9
10
|
async function describeCore(arg1, arg2) {
|
|
10
11
|
let title;
|
|
11
12
|
let cb;
|
|
@@ -14,12 +15,10 @@ async function describeCore(arg1, arg2) {
|
|
|
14
15
|
const FILE = node_process_1.env.FILE;
|
|
15
16
|
if (typeof arg1 === 'string') {
|
|
16
17
|
title = arg1;
|
|
17
|
-
if (typeof arg2 === 'function')
|
|
18
|
+
if (typeof arg2 === 'function')
|
|
18
19
|
cb = arg2;
|
|
19
|
-
|
|
20
|
-
else {
|
|
20
|
+
else
|
|
21
21
|
options = arg2;
|
|
22
|
-
}
|
|
23
22
|
}
|
|
24
23
|
else if (typeof arg1 === 'function') {
|
|
25
24
|
cb = arg1;
|
|
@@ -27,31 +26,28 @@ async function describeCore(arg1, arg2) {
|
|
|
27
26
|
}
|
|
28
27
|
if (title) {
|
|
29
28
|
indentation_js_1.indentation.hasDescribe = true;
|
|
30
|
-
const { background, icon } = options
|
|
31
|
-
const message = `${cb ? (0, format_js_1.format)('◌').dim() : icon
|
|
29
|
+
const { background, icon } = options !== null && options !== void 0 ? options : {};
|
|
30
|
+
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
31
|
const noBackground = !background;
|
|
33
|
-
if (noBackground)
|
|
32
|
+
if (noBackground)
|
|
34
33
|
write_js_1.Write.log((0, format_js_1.format)(message).bold());
|
|
35
|
-
|
|
36
|
-
else {
|
|
34
|
+
else
|
|
37
35
|
write_js_1.Write.log((0, format_js_1.format)(` ${message} `).bg(typeof background === 'string' ? background : 'grey'));
|
|
38
|
-
}
|
|
39
36
|
}
|
|
40
|
-
if (typeof cb !== 'function')
|
|
37
|
+
if (typeof cb !== 'function')
|
|
41
38
|
return;
|
|
42
|
-
}
|
|
43
39
|
const start = (0, node_process_1.hrtime)();
|
|
44
40
|
const resultCb = cb();
|
|
45
|
-
if (resultCb instanceof Promise)
|
|
41
|
+
if (resultCb instanceof Promise)
|
|
46
42
|
await resultCb;
|
|
47
|
-
}
|
|
48
43
|
const end = (0, node_process_1.hrtime)(start);
|
|
49
|
-
if (title)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
44
|
+
if (!title)
|
|
45
|
+
return;
|
|
46
|
+
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
|
|
47
|
+
indentation_js_1.indentation.hasDescribe = false;
|
|
48
|
+
write_js_1.Write.log(`${(0, format_js_1.format)(`● ${title}`).success().bold()} ${(0, format_js_1.format)(`› ${total}ms`).success().dim()}`);
|
|
54
49
|
}
|
|
55
50
|
exports.describe = Object.assign(describeCore, {
|
|
56
51
|
todo: todo_js_1.todo,
|
|
52
|
+
skip: skip_js_1.skip,
|
|
57
53
|
});
|
|
@@ -22,9 +22,8 @@ const each_js_1 = require("../../configs/each.js");
|
|
|
22
22
|
const beforeEach = (callback, options) => {
|
|
23
23
|
(options === null || options === void 0 ? void 0 : options.immediate) && callback();
|
|
24
24
|
each_js_1.each.before.cb = () => {
|
|
25
|
-
if (each_js_1.each.before.status)
|
|
25
|
+
if (each_js_1.each.before.status)
|
|
26
26
|
return callback();
|
|
27
|
-
}
|
|
28
27
|
};
|
|
29
28
|
const pause = () => {
|
|
30
29
|
each_js_1.each.before.status = false;
|
|
@@ -57,9 +56,8 @@ exports.beforeEach = beforeEach;
|
|
|
57
56
|
*/
|
|
58
57
|
const afterEach = (callback) => {
|
|
59
58
|
each_js_1.each.after.cb = () => {
|
|
60
|
-
if (each_js_1.each.after.status)
|
|
59
|
+
if (each_js_1.each.after.status)
|
|
61
60
|
return callback();
|
|
62
|
-
}
|
|
63
61
|
};
|
|
64
62
|
const pause = () => {
|
|
65
63
|
each_js_1.each.after.status = false;
|
|
@@ -23,8 +23,7 @@ const envFile = async (filePath = '.env') => {
|
|
|
23
23
|
mapEnv.set(arg, value ? (0, env_js_1.resolveEnvVariables)(value, node_process_1.env) : value);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
for (const [arg, value] of mapEnv)
|
|
26
|
+
for (const [arg, value] of mapEnv)
|
|
27
27
|
node_process_1.env[arg] = value;
|
|
28
|
-
}
|
|
29
28
|
};
|
|
30
29
|
exports.envFile = envFile;
|
|
@@ -13,7 +13,7 @@ const time_js_1 = require("../../parsers/time.js");
|
|
|
13
13
|
const node_assert_1 = require("assert");
|
|
14
14
|
const exit = (code, quiet) => {
|
|
15
15
|
const isPoku = poku_js_1.results.success > 0 || poku_js_1.results.fail > 0;
|
|
16
|
-
const success = ` PASS › ${poku_js_1.results.success
|
|
16
|
+
const success = ` PASS › ${poku_js_1.results.success} `;
|
|
17
17
|
const failure = ` FAIL › ${poku_js_1.results.fail} `;
|
|
18
18
|
const skips = ` SKIP › ${poku_js_1.results.skip} `;
|
|
19
19
|
const plans = ` TODO › ${poku_js_1.results.todo} `;
|
|
@@ -21,12 +21,10 @@ const exit = (code, quiet) => {
|
|
|
21
21
|
let message = '';
|
|
22
22
|
if (inline) {
|
|
23
23
|
message += `${(0, format_js_1.format)(success).bg('green')} ${(0, format_js_1.format)(failure).bg(poku_js_1.results.fail === 0 ? 'grey' : 'brightRed')}`;
|
|
24
|
-
if (poku_js_1.results.skip)
|
|
24
|
+
if (poku_js_1.results.skip)
|
|
25
25
|
message += ` ${(0, format_js_1.format)(skips).bg('brightBlue')}`;
|
|
26
|
-
|
|
27
|
-
if (poku_js_1.results.todo) {
|
|
26
|
+
if (poku_js_1.results.todo)
|
|
28
27
|
message += ` ${(0, format_js_1.format)(plans).bg('brightBlue')}`;
|
|
29
|
-
}
|
|
30
28
|
}
|
|
31
29
|
else {
|
|
32
30
|
message += `${(0, format_js_1.format)(success).success().bold()}\n`;
|
|
@@ -55,15 +53,13 @@ const exit = (code, quiet) => {
|
|
|
55
53
|
exports.exit = exit;
|
|
56
54
|
|
|
57
55
|
node_process_1.default.on('unhandledRejection', (err) => {
|
|
58
|
-
if (!(err instanceof node_assert_1.AssertionError))
|
|
56
|
+
if (!(err instanceof node_assert_1.AssertionError))
|
|
59
57
|
console.error('unhandledRejection', err);
|
|
60
|
-
}
|
|
61
58
|
node_process_1.default.exitCode = 1;
|
|
62
59
|
});
|
|
63
60
|
node_process_1.default.on('uncaughtException', (err) => {
|
|
64
|
-
if (!(err instanceof node_assert_1.AssertionError))
|
|
61
|
+
if (!(err instanceof node_assert_1.AssertionError))
|
|
65
62
|
console.error('uncaughtException', err);
|
|
66
|
-
}
|
|
67
63
|
node_process_1.default.exitCode = 1;
|
|
68
64
|
});
|
|
69
65
|
|
|
@@ -3,6 +3,7 @@ declare function itCore(message: string, cb: () => unknown): void;
|
|
|
3
3
|
declare function itCore(cb: () => Promise<unknown>): Promise<void>;
|
|
4
4
|
declare function itCore(cb: () => unknown): void;
|
|
5
5
|
export declare const it: typeof itCore & {
|
|
6
|
-
todo: (message: string, _cb?: () => unknown) =>
|
|
6
|
+
todo: (message: string, _cb?: () => unknown) => boolean;
|
|
7
|
+
skip: (message: string, _cb?: () => unknown) => boolean;
|
|
7
8
|
};
|
|
8
9
|
export {};
|