poku 2.2.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 +4 -4
- package/lib/modules/essentials/poku.js +0 -8
- package/lib/modules/helpers/each.js +2 -2
- package/lib/modules/helpers/it.js +8 -12
- 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 +2 -2
package/README.md
CHANGED
|
@@ -221,7 +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**
|
|
224
|
+
- [Using **Poku** without installing on **Deno** and alternatives to **JSR**](https://github.com/wellwelwel/poku/discussions/565).
|
|
225
225
|
|
|
226
226
|
---
|
|
227
227
|
|
|
@@ -243,9 +243,9 @@ To see the detailed documentation, please visit the [**Documentation**](https://
|
|
|
243
243
|
|
|
244
244
|
[](https://pkg-size.dev/poku)
|
|
245
245
|
|
|
246
|
-
- [~**
|
|
247
|
-
- [~**
|
|
248
|
-
- [~**
|
|
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)
|
|
249
249
|
|
|
250
250
|
> **Poku** size is highly significant in development to ensure cost-saving **CI** that require servers that charge for storage and usage.
|
|
251
251
|
|
|
@@ -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 = () => {
|
|
@@ -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
|
}
|
|
@@ -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.2.
|
|
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",
|
|
@@ -65,7 +65,7 @@
|
|
|
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
|
"🐷",
|