poku 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/lib/bin/index.js +16 -10
- package/lib/modules/essentials/poku.js +0 -8
- package/lib/modules/helpers/each.js +2 -2
- package/lib/modules/helpers/it.d.ts +1 -1
- package/lib/modules/helpers/it.js +8 -12
- package/lib/modules/helpers/test.d.ts +1 -1
- package/lib/modules/helpers/test.js +8 -12
- package/lib/parsers/assert.js +1 -1
- package/lib/parsers/output.js +0 -1
- package/lib/services/assert.js +0 -1
- package/lib/services/each.js +0 -1
- package/lib/services/map-tests.d.ts +2 -0
- package/lib/services/map-tests.js +6 -9
- package/lib/services/run-test-file.js +0 -2
- package/lib/services/run-tests.js +0 -3
- package/lib/services/watch.js +0 -2
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -28,8 +28,8 @@ Enjoying **Poku**? Give him a star to show your support 🌟
|
|
|
28
28
|
</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> **Performant** and **lightweight**<br />
|
|
29
29
|
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run **CommonJS** files directly with [**Deno**][deno-version-url]<br />
|
|
30
30
|
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Auto detect **ESM**, **CJS**, and **TypeScript** files<br />
|
|
31
|
-
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run the same test suite for [**Node.js**][node-version-url], [**Bun**][bun-version-url], and [**Deno**][deno-version-url]<br />
|
|
32
|
-
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **servers**, **processes**, **ports**, and **containers
|
|
31
|
+
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run the **same test suite** for [**Node.js**][node-version-url], [**Bun**][bun-version-url], and [**Deno**][deno-version-url]<br />
|
|
32
|
+
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **servers**, **processes**, **ports**, and **containers** ✨
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
@@ -221,6 +221,7 @@ To see the detailed documentation, please visit the [**Documentation**](https://
|
|
|
221
221
|
- [Avoiding conflicts in environments with multiple platforms installed](https://poku.io/docs/tutorials/cross-platform#recommendations).
|
|
222
222
|
- [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises).
|
|
223
223
|
- [Migrating from version **1.x** to version **2.x**](https://github.com/wellwelwel/poku/issues/533).
|
|
224
|
+
- [Using **Poku** without installing on **Deno** and alternatives to **JSR**](https://github.com/wellwelwel/poku/discussions/565).
|
|
224
225
|
|
|
225
226
|
---
|
|
226
227
|
|
|
@@ -242,9 +243,9 @@ To see the detailed documentation, please visit the [**Documentation**](https://
|
|
|
242
243
|
|
|
243
244
|
[](https://pkg-size.dev/poku)
|
|
244
245
|
|
|
245
|
-
- [~**
|
|
246
|
-
- [~**
|
|
247
|
-
- [~**
|
|
246
|
+
- [~**230x** lighter than **Vitest**](https://pkg-size.dev/vitest)
|
|
247
|
+
- [~**130x** lighter than **Jest**](https://pkg-size.dev/jest)
|
|
248
|
+
- [~**30x** lighter than **Mocha** + **Chai**](https://pkg-size.dev/mocha%20chai)
|
|
248
249
|
|
|
249
250
|
> **Poku** size is highly significant in development to ensure cost-saving **CI** that require servers that charge for storage and usage.
|
|
250
251
|
|
package/lib/bin/index.js
CHANGED
|
@@ -19,15 +19,15 @@ const write_js_1 = require("../services/write.js");
|
|
|
19
19
|
const options_js_1 = require("../parsers/options.js");
|
|
20
20
|
(async () => {
|
|
21
21
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
22
|
-
const configFile = (0, get_arg_js_1.getArg)('config');
|
|
22
|
+
const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');
|
|
23
23
|
const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
|
|
24
24
|
const dirs = (() => {
|
|
25
25
|
var _a;
|
|
26
|
-
const includeArg = (0, get_arg_js_1.getArg)('include');
|
|
26
|
+
const includeArg = (0, get_arg_js_1.getArg)('include'); // deprecated
|
|
27
27
|
if (includeArg !== undefined) {
|
|
28
28
|
return includeArg.split(',');
|
|
29
29
|
}
|
|
30
|
-
return ((_a = (0, get_arg_js_1.getPaths)()) !== null && _a !== void 0 ? _a : ((defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.include)
|
|
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
|
: ['.']));
|
|
33
33
|
})();
|
|
@@ -42,11 +42,11 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
42
42
|
const denoCJS = ((_g = (0, get_arg_js_1.getArg)('deno-cjs')) === null || _g === void 0 ? void 0 : _g.split(',').map((a) => a.trim()).filter((a) => a)) ||
|
|
43
43
|
(0, get_arg_js_1.hasArg)('deno-cjs') ||
|
|
44
44
|
((_h = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _h === void 0 ? void 0 : _h.cjs);
|
|
45
|
-
const parallel = (0, get_arg_js_1.hasArg)('parallel') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel);
|
|
46
|
-
const quiet = (0, get_arg_js_1.hasArg)('quiet') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.quiet);
|
|
47
|
-
const debug = (0, get_arg_js_1.hasArg)('debug') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.debug);
|
|
45
|
+
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);
|
|
46
|
+
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);
|
|
47
|
+
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);
|
|
48
48
|
const failFast = (0, get_arg_js_1.hasArg)('fail-fast') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.failFast);
|
|
49
|
-
const watchMode = (0, get_arg_js_1.hasArg)('watch');
|
|
49
|
+
const watchMode = (0, get_arg_js_1.hasArg)('watch') || (0, get_arg_js_1.hasArg)('w', '-');
|
|
50
50
|
const hasEnvFile = (0, get_arg_js_1.hasArg)('env-file');
|
|
51
51
|
const concurrency = (() => {
|
|
52
52
|
if (!(parallel || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel))) {
|
|
@@ -82,9 +82,15 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
82
82
|
const options = {
|
|
83
83
|
platform: (0, get_runtime_js_1.platformIsValid)(platform)
|
|
84
84
|
? platform
|
|
85
|
-
: (0,
|
|
86
|
-
?
|
|
87
|
-
:
|
|
85
|
+
: (0, get_arg_js_1.hasArg)('node')
|
|
86
|
+
? 'node'
|
|
87
|
+
: (0, get_arg_js_1.hasArg)('bun')
|
|
88
|
+
? 'bun'
|
|
89
|
+
: (0, get_arg_js_1.hasArg)('deno')
|
|
90
|
+
? 'deno'
|
|
91
|
+
: (0, get_runtime_js_1.platformIsValid)(defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform)
|
|
92
|
+
? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.platform
|
|
93
|
+
: undefined,
|
|
88
94
|
filter: typeof filter === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : filter,
|
|
89
95
|
exclude: typeof exclude === 'string' ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude)) : exclude,
|
|
90
96
|
parallel,
|
|
@@ -25,14 +25,12 @@ async function poku(targetPaths, configs) {
|
|
|
25
25
|
files_js_1.finalResults.started = new Date();
|
|
26
26
|
const start = node_process_1.default.hrtime();
|
|
27
27
|
const prepareDirs = Array.prototype.concat(targetPaths);
|
|
28
|
-
/* c8 ignore next */ // TODO: Allow users to pass cwd for monorepo improvements
|
|
29
28
|
const dirs = prepareDirs.length > 0 ? prepareDirs : ['.'];
|
|
30
29
|
const showLogs = !(0, output_js_1.isQuiet)(configs);
|
|
31
30
|
// Sequential
|
|
32
31
|
if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) {
|
|
33
32
|
for (const dir of dirs) {
|
|
34
33
|
const result = await (0, run_tests_js_1.runTests)(dir, configs);
|
|
35
|
-
/* c8 ignore next 6 */
|
|
36
34
|
if (!result) {
|
|
37
35
|
code = 1;
|
|
38
36
|
if (configs === null || configs === void 0 ? void 0 : configs.failFast) {
|
|
@@ -52,24 +50,20 @@ async function poku(targetPaths, configs) {
|
|
|
52
50
|
// Parallel
|
|
53
51
|
if (showLogs) {
|
|
54
52
|
write_js_1.Write.hr();
|
|
55
|
-
/* c8 ignore next */ // ?
|
|
56
53
|
write_js_1.Write.log(`${(0, format_js_1.format)('Running the Test Suite in Parallel').bold()}\n`);
|
|
57
54
|
}
|
|
58
55
|
try {
|
|
59
56
|
const promises = dirs.map(async (dir) => {
|
|
60
57
|
const result = await (0, run_tests_js_1.runTestsParallel)(dir, configs);
|
|
61
|
-
/* c8 ignore next 3 */
|
|
62
58
|
if (!result && (configs === null || configs === void 0 ? void 0 : configs.failFast)) {
|
|
63
59
|
throw new Error('quiet');
|
|
64
60
|
}
|
|
65
61
|
return result;
|
|
66
62
|
});
|
|
67
63
|
const concurrency = await Promise.all(promises);
|
|
68
|
-
/* c8 ignore next 3 */
|
|
69
64
|
if (concurrency.some((result) => !result)) {
|
|
70
65
|
code = 1;
|
|
71
66
|
}
|
|
72
|
-
/* c8 ignore next */
|
|
73
67
|
}
|
|
74
68
|
catch (_a) {
|
|
75
69
|
}
|
|
@@ -84,13 +78,11 @@ async function poku(targetPaths, configs) {
|
|
|
84
78
|
.map(([file, time]) => `${indentation_js_1.indentation.test}${(0, format_js_1.format)('✔').success()} ${(0, format_js_1.format)(`${file} ${(0, format_js_1.format)(`› ${time}ms`).success()}`).dim()}`)
|
|
85
79
|
.join('\n'));
|
|
86
80
|
}
|
|
87
|
-
/* c8 ignore start */
|
|
88
81
|
if (showLogs && files_js_1.fileResults.fail.size > 0) {
|
|
89
82
|
write_js_1.Write.log(Array.from(files_js_1.fileResults.fail)
|
|
90
83
|
.map(([file, time]) => `${indentation_js_1.indentation.test}${(0, format_js_1.format)('✘').fail()} ${(0, format_js_1.format)(`${file} ${(0, format_js_1.format)(`› ${time}ms`).fail()}`).dim()}`)
|
|
91
84
|
.join('\n'));
|
|
92
85
|
}
|
|
93
|
-
/* c8 ignore stop */
|
|
94
86
|
if (configs === null || configs === void 0 ? void 0 : configs.noExit) {
|
|
95
87
|
return code;
|
|
96
88
|
}
|
|
@@ -23,7 +23,7 @@ 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
25
|
if (each_js_1.each.before.status) {
|
|
26
|
-
callback();
|
|
26
|
+
return callback();
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
const pause = () => {
|
|
@@ -59,7 +59,7 @@ exports.beforeEach = beforeEach;
|
|
|
59
59
|
const afterEach = (callback) => {
|
|
60
60
|
each_js_1.each.after.cb = () => {
|
|
61
61
|
if (each_js_1.each.after.status) {
|
|
62
|
-
callback();
|
|
62
|
+
return callback();
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
const pause = () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function it(message: string, cb: () => Promise<unknown>): Promise<void>;
|
|
2
|
-
export declare function it(message: string, cb: () => unknown):
|
|
2
|
+
export declare function it(message: string, cb: () => unknown): void;
|
|
3
3
|
export declare function it(cb: () => Promise<unknown>): Promise<void>;
|
|
4
4
|
export declare function it(cb: () => unknown): void;
|
|
@@ -13,13 +13,6 @@ async function it(...args) {
|
|
|
13
13
|
let cb;
|
|
14
14
|
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
|
|
15
15
|
const FILE = node_process_1.env.FILE;
|
|
16
|
-
if (typeof each_js_1.each.before.cb === 'function') {
|
|
17
|
-
const beforeResult = each_js_1.each.before.cb();
|
|
18
|
-
/* c8 ignore next 3 */
|
|
19
|
-
if (beforeResult instanceof Promise) {
|
|
20
|
-
await beforeResult;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
16
|
if (typeof args[0] === 'string') {
|
|
24
17
|
message = args[0];
|
|
25
18
|
cb = args[1];
|
|
@@ -27,24 +20,27 @@ async function it(...args) {
|
|
|
27
20
|
else {
|
|
28
21
|
cb = args[0];
|
|
29
22
|
}
|
|
30
|
-
/* c8 ignore start */
|
|
31
23
|
if (message) {
|
|
32
24
|
indentation_js_1.indentation.hasIt = true;
|
|
33
25
|
write_js_1.Write.log(isPoku && !indentation_js_1.indentation.hasDescribe
|
|
34
|
-
?
|
|
26
|
+
? /* c8 ignore next 2 */
|
|
27
|
+
`${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`◌ ${message} › ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()}`
|
|
35
28
|
: `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`◌ ${message}`).dim()}`);
|
|
36
29
|
}
|
|
37
|
-
|
|
30
|
+
if (typeof each_js_1.each.before.cb === 'function') {
|
|
31
|
+
const beforeResult = each_js_1.each.before.cb();
|
|
32
|
+
if (beforeResult instanceof Promise) {
|
|
33
|
+
await beforeResult;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
38
36
|
const start = (0, node_process_1.hrtime)();
|
|
39
37
|
const resultCb = cb();
|
|
40
|
-
/* c8 ignore next 3 */
|
|
41
38
|
if (resultCb instanceof Promise) {
|
|
42
39
|
await resultCb;
|
|
43
40
|
}
|
|
44
41
|
const end = (0, node_process_1.hrtime)(start);
|
|
45
42
|
if (typeof each_js_1.each.after.cb === 'function') {
|
|
46
43
|
const afterResult = each_js_1.each.after.cb();
|
|
47
|
-
/* c8 ignore next 3 */
|
|
48
44
|
if (afterResult instanceof Promise) {
|
|
49
45
|
await afterResult;
|
|
50
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function test(message: string, cb: () => Promise<unknown>): Promise<void>;
|
|
2
|
-
export declare function test(message: string, cb: () => unknown):
|
|
2
|
+
export declare function test(message: string, cb: () => unknown): void;
|
|
3
3
|
export declare function test(cb: () => Promise<unknown>): Promise<void>;
|
|
4
4
|
export declare function test(cb: () => unknown): void;
|
|
@@ -13,13 +13,6 @@ async function test(...args) {
|
|
|
13
13
|
let cb;
|
|
14
14
|
const isPoku = typeof (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE) === 'string' && (node_process_1.env === null || node_process_1.env === void 0 ? void 0 : node_process_1.env.FILE.length) > 0;
|
|
15
15
|
const FILE = node_process_1.env.FILE;
|
|
16
|
-
if (typeof each_js_1.each.before.cb === 'function') {
|
|
17
|
-
const beforeResult = each_js_1.each.before.cb();
|
|
18
|
-
/* c8 ignore next 3 */
|
|
19
|
-
if (beforeResult instanceof Promise) {
|
|
20
|
-
await beforeResult;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
16
|
if (typeof args[0] === 'string') {
|
|
24
17
|
message = args[0];
|
|
25
18
|
cb = args[1];
|
|
@@ -27,24 +20,27 @@ async function test(...args) {
|
|
|
27
20
|
else {
|
|
28
21
|
cb = args[0];
|
|
29
22
|
}
|
|
30
|
-
/* c8 ignore start */
|
|
31
23
|
if (message) {
|
|
32
24
|
indentation_js_1.indentation.hasTest = true;
|
|
33
25
|
write_js_1.Write.log(isPoku
|
|
34
|
-
?
|
|
26
|
+
? /* c8 ignore next 2 */
|
|
27
|
+
(0, format_js_1.format)(`◌ ${message} › ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()
|
|
35
28
|
: (0, format_js_1.format)(`◌ ${message}`).dim());
|
|
36
29
|
}
|
|
37
|
-
|
|
30
|
+
if (typeof each_js_1.each.before.cb === 'function') {
|
|
31
|
+
const beforeResult = each_js_1.each.before.cb();
|
|
32
|
+
if (beforeResult instanceof Promise) {
|
|
33
|
+
await beforeResult;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
38
36
|
const start = (0, node_process_1.hrtime)();
|
|
39
37
|
const resultCb = cb();
|
|
40
|
-
/* c8 ignore next 3 */
|
|
41
38
|
if (resultCb instanceof Promise) {
|
|
42
39
|
await resultCb;
|
|
43
40
|
}
|
|
44
41
|
const end = (0, node_process_1.hrtime)(start);
|
|
45
42
|
if (typeof each_js_1.each.after.cb === 'function') {
|
|
46
43
|
const afterResult = each_js_1.each.after.cb();
|
|
47
|
-
/* c8 ignore next 3 */
|
|
48
44
|
if (afterResult instanceof Promise) {
|
|
49
45
|
await afterResult;
|
|
50
46
|
}
|
package/lib/parsers/assert.js
CHANGED
|
@@ -20,7 +20,7 @@ const parseResultType = (type) => {
|
|
|
20
20
|
if (value instanceof Set) {
|
|
21
21
|
return Array.from(value).map(recurse);
|
|
22
22
|
}
|
|
23
|
-
/* c8 ignore start */
|
|
23
|
+
/* c8 ignore start */
|
|
24
24
|
if (value instanceof Map) {
|
|
25
25
|
return recurse(!get_runtime_js_1.nodeVersion || get_runtime_js_1.nodeVersion >= 12
|
|
26
26
|
? Object.fromEntries(value)
|
package/lib/parsers/output.js
CHANGED
|
@@ -9,7 +9,6 @@ const regex = {
|
|
|
9
9
|
};
|
|
10
10
|
const isQuiet = (configs) => typeof (configs === null || configs === void 0 ? void 0 : configs.quiet) === 'boolean' && Boolean(configs === null || configs === void 0 ? void 0 : configs.quiet);
|
|
11
11
|
exports.isQuiet = isQuiet;
|
|
12
|
-
/* c8 ignore next */
|
|
13
12
|
const isDebug = (configs) => Boolean(configs === null || configs === void 0 ? void 0 : configs.debug);
|
|
14
13
|
exports.isDebug = isDebug;
|
|
15
14
|
/* c8 ignore next */ // ?
|
package/lib/services/assert.js
CHANGED
package/lib/services/each.js
CHANGED
|
@@ -5,7 +5,6 @@ const format_js_1 = require("./format.js");
|
|
|
5
5
|
const write_js_1 = require("../services/write.js");
|
|
6
6
|
const output_js_1 = require("../parsers/output.js");
|
|
7
7
|
const eachCore = async (type, fileRelative, configs) => {
|
|
8
|
-
/* c8 ignore next 3 */
|
|
9
8
|
if (typeof (configs === null || configs === void 0 ? void 0 : configs[type]) !== 'function') {
|
|
10
9
|
return true;
|
|
11
10
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const normalizePath: (filePath: string) => string;
|
|
2
2
|
export declare const getDeepImports: (content: string) => Set<string>;
|
|
3
3
|
export declare const findMatchingFiles: (srcFilesWithoutExt: Set<string>, srcFilesWithExt: Set<string>) => Set<string>;
|
|
4
|
+
export declare const processDeepImports: (srcFile: string, testFile: string, intersectedSrcFiles: Set<string>) => Promise<void>;
|
|
5
|
+
export declare const createImportMap: (allTestFiles: Set<string>, allSrcFiles: Set<string>) => Promise<void>;
|
|
4
6
|
export declare const mapTests: (srcDir: string, testPaths: string[], testFilter?: RegExp, exclude?: RegExp | RegExp[]) => Promise<Map<string, Set<string>>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapTests = exports.findMatchingFiles = exports.getDeepImports = exports.normalizePath = void 0;
|
|
3
|
+
exports.mapTests = exports.createImportMap = exports.processDeepImports = exports.findMatchingFiles = exports.getDeepImports = exports.normalizePath = void 0;
|
|
4
4
|
/* c8 ignore next */ // ?
|
|
5
5
|
const node_path_1 = require("path");
|
|
6
6
|
const fs_js_1 = require("../polyfills/fs.js");
|
|
@@ -63,13 +63,11 @@ const collectTestFiles = async (testPaths, testFilter, exclude) => {
|
|
|
63
63
|
if (stat.isFile() && regex.extFilter.test(testPath)) {
|
|
64
64
|
return [testPath];
|
|
65
65
|
}
|
|
66
|
-
/* c8 ignore next */
|
|
67
66
|
return [];
|
|
68
67
|
});
|
|
69
68
|
const nestedTestFiles = await Promise.all(listFilesPromises);
|
|
70
69
|
return new Set(nestedTestFiles.flat());
|
|
71
70
|
};
|
|
72
|
-
/* c8 ignore start */
|
|
73
71
|
const processDeepImports = async (srcFile, testFile, intersectedSrcFiles) => {
|
|
74
72
|
if (processedFiles.has(srcFile)) {
|
|
75
73
|
return;
|
|
@@ -83,11 +81,10 @@ const processDeepImports = async (srcFile, testFile, intersectedSrcFiles) => {
|
|
|
83
81
|
importMap.set(deepImport, new Set());
|
|
84
82
|
}
|
|
85
83
|
importMap.get(deepImport).add((0, exports.normalizePath)(testFile));
|
|
86
|
-
await processDeepImports(deepImport, testFile, intersectedSrcFiles);
|
|
84
|
+
await (0, exports.processDeepImports)(deepImport, testFile, intersectedSrcFiles);
|
|
87
85
|
}
|
|
88
86
|
};
|
|
89
|
-
|
|
90
|
-
/* c8 ignore start */
|
|
87
|
+
exports.processDeepImports = processDeepImports;
|
|
91
88
|
const createImportMap = async (allTestFiles, allSrcFiles) => {
|
|
92
89
|
const intersectedSrcFiles = new Set(Array.from(allSrcFiles).filter((srcFile) => !allTestFiles.has(srcFile)));
|
|
93
90
|
await Promise.all(Array.from(allTestFiles).map(async (testFile) => {
|
|
@@ -102,12 +99,12 @@ const createImportMap = async (allTestFiles, allSrcFiles) => {
|
|
|
102
99
|
importMap.set(normalizedSrcFile, new Set());
|
|
103
100
|
}
|
|
104
101
|
(_a = importMap.get(normalizedSrcFile)) === null || _a === void 0 ? void 0 : _a.add((0, exports.normalizePath)(testFile));
|
|
105
|
-
await processDeepImports(srcFile, testFile, intersectedSrcFiles);
|
|
102
|
+
await (0, exports.processDeepImports)(srcFile, testFile, intersectedSrcFiles);
|
|
106
103
|
}
|
|
107
104
|
}
|
|
108
105
|
}));
|
|
109
106
|
};
|
|
110
|
-
|
|
107
|
+
exports.createImportMap = createImportMap;
|
|
111
108
|
/* c8 ignore next */ // ?
|
|
112
109
|
const mapTests = async (srcDir, testPaths, testFilter, exclude) => {
|
|
113
110
|
const [allTestFiles, allSrcFiles] = await Promise.all([
|
|
@@ -117,7 +114,7 @@ const mapTests = async (srcDir, testPaths, testFilter, exclude) => {
|
|
|
117
114
|
exclude,
|
|
118
115
|
}),
|
|
119
116
|
]);
|
|
120
|
-
await createImportMap(allTestFiles, new Set(allSrcFiles));
|
|
117
|
+
await (0, exports.createImportMap)(allTestFiles, new Set(allSrcFiles));
|
|
121
118
|
return importMap;
|
|
122
119
|
};
|
|
123
120
|
exports.mapTests = mapTests;
|
|
@@ -39,7 +39,6 @@ const runTestFile = async (filePath, configs) => {
|
|
|
39
39
|
}
|
|
40
40
|
const start = (0, node_process_1.hrtime)();
|
|
41
41
|
let end;
|
|
42
|
-
/* c8 ignore next 3 */
|
|
43
42
|
if (!(await (0, each_js_1.beforeEach)(fileRelative, configs))) {
|
|
44
43
|
return false;
|
|
45
44
|
}
|
|
@@ -66,7 +65,6 @@ const runTestFile = async (filePath, configs) => {
|
|
|
66
65
|
});
|
|
67
66
|
mappedOutputs && write_js_1.Write.log(mappedOutputs.join('\n'));
|
|
68
67
|
}
|
|
69
|
-
/* c8 ignore next 4 */
|
|
70
68
|
if (!(await (0, each_js_1.afterEach)(fileRelative, configs))) {
|
|
71
69
|
resolve(false);
|
|
72
70
|
return;
|
|
@@ -84,12 +84,10 @@ const runTestsParallel = async (dir, configs) => {
|
|
|
84
84
|
try {
|
|
85
85
|
for (const fileGroup of filesByConcurrency) {
|
|
86
86
|
const promises = fileGroup.map(async (filePath) => {
|
|
87
|
-
/* c8 ignore next 3 */
|
|
88
87
|
if ((configs === null || configs === void 0 ? void 0 : configs.failFast) && poku_js_1.results.fail > 0) {
|
|
89
88
|
return;
|
|
90
89
|
}
|
|
91
90
|
const testPassed = await (0, run_test_file_js_1.runTestFile)(filePath, configs);
|
|
92
|
-
/* c8 ignore start */
|
|
93
91
|
if (!testPassed) {
|
|
94
92
|
++poku_js_1.results.fail;
|
|
95
93
|
if (configs === null || configs === void 0 ? void 0 : configs.failFast) {
|
|
@@ -97,7 +95,6 @@ const runTestsParallel = async (dir, configs) => {
|
|
|
97
95
|
}
|
|
98
96
|
return false;
|
|
99
97
|
}
|
|
100
|
-
/* c8 ignore false */
|
|
101
98
|
++poku_js_1.results.success;
|
|
102
99
|
return true;
|
|
103
100
|
});
|
package/lib/services/watch.js
CHANGED
|
@@ -14,7 +14,6 @@ class Watcher {
|
|
|
14
14
|
this.callback = callback;
|
|
15
15
|
}
|
|
16
16
|
watchFile(filePath) {
|
|
17
|
-
/* c8 ignore next 3 */
|
|
18
17
|
if (this.fileWatchers.has(filePath)) {
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
@@ -40,7 +39,6 @@ class Watcher {
|
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
async watchDirectory(dir) {
|
|
43
|
-
/* c8 ignore next 3 */
|
|
44
42
|
if (this.dirWatchers.has(dir)) {
|
|
45
43
|
return;
|
|
46
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poku",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",
|
|
5
5
|
"main": "./lib/modules/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"test": "npm run test:parallel && npm run test:sequential",
|
|
34
34
|
"test:bun": "npm run test:bun:parallel && npm run test:bun:sequential",
|
|
35
35
|
"test:deno": "npm run test:deno:parallel && npm run test:deno:sequential",
|
|
36
|
-
"test:sequential": "tsx src/bin/index.ts
|
|
37
|
-
"test:parallel": "tsx src/bin/index.ts
|
|
38
|
-
"test:bun:sequential": "bun src/bin/index.ts --
|
|
39
|
-
"test:bun:parallel": "bun src/bin/index.ts --
|
|
40
|
-
"test:deno:sequential": "tsx src/bin/index.ts --
|
|
41
|
-
"test:deno:parallel": "tsx src/bin/index.ts --
|
|
36
|
+
"test:sequential": "tsx src/bin/index.ts test/unit test/integration test/e2e",
|
|
37
|
+
"test:parallel": "tsx src/bin/index.ts -p test/unit test/integration test/e2e",
|
|
38
|
+
"test:bun:sequential": "bun src/bin/index.ts --bun test/unit test/integration test/e2e",
|
|
39
|
+
"test:bun:parallel": "bun src/bin/index.ts --bun -p test/unit test/integration test/e2e",
|
|
40
|
+
"test:deno:sequential": "tsx src/bin/index.ts --deno --deno-allow=all --deno-cjs ci/test/unit ci/test/integration ci/test/e2e",
|
|
41
|
+
"test:deno:parallel": "tsx src/bin/index.ts --deno --deno-allow=all --deno-cjs -p ci/test/unit ci/test/integration ci/test/e2e",
|
|
42
42
|
"test:c8": "c8 tsx test/c8.test.ts",
|
|
43
43
|
"test:ci": "tsx test/ci.test.ts",
|
|
44
44
|
"test:ci:node": "FILTER='node-' npm run test:ci",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"test:ci:deno": "FILTER='deno-' npm run test:ci",
|
|
47
47
|
"predocker:deno": "docker compose -f test/docker/playground/deno/docker-compose.yml down",
|
|
48
48
|
"docker:deno": "docker compose -f test/docker/playground/deno/docker-compose.yml up --build",
|
|
49
|
-
"clear": "rm -rf lib ci coverage",
|
|
49
|
+
"clear": "rm -rf lib ci coverage .temp test-src test-tests",
|
|
50
50
|
"prebuild": "npm run clear",
|
|
51
51
|
"build": "tsc && tsc -p tsconfig.test.json",
|
|
52
52
|
"postbuild": "tsx tools/compatibility/node.ts && cp fixtures/server/package.json ci/fixtures/server/package.json && npm run build:deno && chmod +x lib/bin/index.js",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@biomejs/biome": "1.8.3",
|
|
63
|
-
"@types/node": "^20.14.
|
|
63
|
+
"@types/node": "^20.14.11",
|
|
64
64
|
"c8": "^10.1.2",
|
|
65
65
|
"packages-update": "^2.0.0",
|
|
66
66
|
"prettier": "^3.3.3",
|
|
67
67
|
"tsx": "4.16.2",
|
|
68
|
-
"typescript": "^5.5.
|
|
68
|
+
"typescript": "^5.5.4"
|
|
69
69
|
},
|
|
70
70
|
"keywords": [
|
|
71
71
|
"🐷",
|