poku 2.2.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -7
- package/lib/@types/poku.d.ts +3 -0
- package/lib/bin/index.js +19 -2
- package/lib/configs/files.d.ts +2 -1
- package/lib/configs/files.js +2 -1
- package/lib/configs/poku.d.ts +2 -1
- package/lib/configs/poku.js +2 -1
- package/lib/modules/essentials/assert.js +0 -2
- package/lib/modules/essentials/poku.js +6 -19
- package/lib/modules/essentials/strict.js +0 -2
- package/lib/modules/helpers/container.js +0 -1
- package/lib/modules/helpers/describe.d.ts +9 -6
- package/lib/modules/helpers/describe.js +7 -4
- package/lib/modules/helpers/each.d.ts +2 -2
- package/lib/modules/helpers/each.js +2 -3
- package/lib/modules/helpers/env.js +0 -2
- package/lib/modules/helpers/exit.js +27 -1
- package/lib/modules/helpers/it/core.d.ts +8 -0
- package/lib/modules/helpers/{it.js → it/core.js} +11 -9
- package/lib/modules/helpers/it/todo.d.ts +1 -0
- package/lib/modules/helpers/it/todo.js +10 -0
- package/lib/modules/helpers/list-files.js +14 -5
- package/lib/modules/helpers/skip.js +3 -3
- package/lib/modules/helpers/test.d.ts +8 -2
- package/lib/modules/helpers/test.js +2 -4
- package/lib/modules/helpers/wait-for.js +0 -4
- package/lib/modules/index.d.ts +1 -1
- package/lib/modules/index.js +2 -2
- package/lib/parsers/assert.js +2 -4
- package/lib/parsers/find-file-from-stack.js +0 -2
- package/lib/parsers/get-arg.js +0 -2
- package/lib/parsers/get-runner.js +1 -1
- package/lib/parsers/options.js +0 -1
- package/lib/parsers/output.js +7 -4
- package/lib/parsers/time.js +0 -2
- package/lib/polyfills/cpus.js +2 -2
- package/lib/polyfills/object.js +1 -1
- package/lib/services/assert.js +3 -6
- package/lib/services/container.js +3 -3
- package/lib/services/each.js +0 -1
- package/lib/services/env.js +0 -3
- package/lib/services/format.d.ts +2 -0
- package/lib/services/format.js +22 -3
- package/lib/services/map-tests.js +0 -2
- package/lib/services/run-test-file.js +2 -5
- package/lib/services/run-tests.js +4 -16
- package/lib/services/watch.js +8 -22
- package/lib/services/write.js +0 -1
- package/package.json +9 -5
- package/lib/@types/assert.js +0 -2
- package/lib/@types/background-process.js +0 -2
- package/lib/@types/code.js +0 -2
- package/lib/@types/container.js +0 -2
- package/lib/@types/describe.js +0 -2
- package/lib/@types/each.js +0 -2
- package/lib/@types/list-files.js +0 -2
- package/lib/@types/poku.js +0 -2
- package/lib/@types/runner.js +0 -2
- package/lib/@types/wait-for.js +0 -2
- package/lib/@types/watch.js +0 -2
- package/lib/bin/index.d.ts +0 -2
- package/lib/modules/helpers/it.d.ts +0 -4
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Enjoying **Poku**? Give him a star to show your support 🌟
|
|
|
7
7
|
|
|
8
8
|
[](https://www.npmjs.com/package/poku)
|
|
9
9
|
[](https://www.npmjs.com/package/poku)
|
|
10
|
-
[](https://
|
|
10
|
+
[](https://github.com/wellwelwel/poku/tree/main/.nycrc)<br />
|
|
11
11
|
[](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain)
|
|
12
12
|
[](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-osx.yml?query=branch%3Amain)
|
|
13
13
|
[](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-windows.yml?query=branch%3Amain)
|
|
@@ -29,7 +29,7 @@ Enjoying **Poku**? Give him a star to show your support 🌟
|
|
|
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
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** ✨
|
|
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 even **containers** ✨
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
@@ -37,20 +37,43 @@ Enjoying **Poku**? Give him a star to show your support 🌟
|
|
|
37
37
|
|
|
38
38
|
### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Install
|
|
39
39
|
|
|
40
|
+
<table>
|
|
41
|
+
<tr>
|
|
42
|
+
<td width="225">
|
|
43
|
+
|
|
40
44
|
```bash
|
|
41
45
|
# Node.js
|
|
42
46
|
npm i -D poku
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
</td>
|
|
50
|
+
<td width="225">
|
|
43
51
|
|
|
52
|
+
```bash
|
|
44
53
|
# TypeScript (Node.js)
|
|
45
54
|
npm i -D poku tsx
|
|
55
|
+
```
|
|
46
56
|
|
|
57
|
+
</td>
|
|
58
|
+
<td width="225">
|
|
59
|
+
|
|
60
|
+
```bash
|
|
47
61
|
# Bun
|
|
48
62
|
bun add -d poku
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
</td>
|
|
66
|
+
<td width="225">
|
|
49
67
|
|
|
50
|
-
|
|
68
|
+
```bash
|
|
69
|
+
# Deno (optional)
|
|
51
70
|
deno add npm:poku
|
|
52
71
|
```
|
|
53
72
|
|
|
73
|
+
</td>
|
|
74
|
+
</tr>
|
|
75
|
+
</table>
|
|
76
|
+
|
|
54
77
|
---
|
|
55
78
|
|
|
56
79
|
### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Test
|
|
@@ -220,8 +243,8 @@ To see the detailed documentation, please visit the [**Documentation**](https://
|
|
|
220
243
|
|
|
221
244
|
- [Avoiding conflicts in environments with multiple platforms installed](https://poku.io/docs/tutorials/cross-platform#recommendations).
|
|
222
245
|
- [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises).
|
|
223
|
-
- [Migrating from version **1.x** to version **2.x**](https://github.com/wellwelwel/poku/issues/533).
|
|
224
246
|
- [Using **Poku** without installing on **Deno** and alternatives to **JSR**](https://github.com/wellwelwel/poku/discussions/565).
|
|
247
|
+
- [Migrating from version **1.x** to version **2.x**](https://github.com/wellwelwel/poku/issues/533).
|
|
225
248
|
|
|
226
249
|
---
|
|
227
250
|
|
|
@@ -231,9 +254,9 @@ To see the detailed documentation, please visit the [**Documentation**](https://
|
|
|
231
254
|
|
|
232
255
|
**Poku** is [continuously tested](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml) to ensure the following expectations for basic usage:
|
|
233
256
|
|
|
234
|
-
-
|
|
235
|
-
-
|
|
236
|
-
-
|
|
257
|
+
- ~**4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0)
|
|
258
|
+
- ~**3x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v1.6.0)
|
|
259
|
+
- ~**1x** faster than [**Mocha**](https://github.com/mochajs/mocha) (v10.4.0) + [**Chai**](https://github.com/chaijs/chai) (v5.1.1)
|
|
237
260
|
|
|
238
261
|
> You can see how the tests are run and compared in the [benchmark](https://github.com/wellwelwel/poku/tree/main/benchmark) directory.
|
|
239
262
|
|
package/lib/@types/poku.d.ts
CHANGED
|
@@ -83,6 +83,9 @@ export type FinalResults = {
|
|
|
83
83
|
time: string;
|
|
84
84
|
started: Date;
|
|
85
85
|
};
|
|
86
|
+
export type States = {
|
|
87
|
+
isSinglePath?: boolean;
|
|
88
|
+
};
|
|
86
89
|
type cliConfigs = {
|
|
87
90
|
/** By default, **Poku** searches for _`.test.`_ and `.spec.` files, but you can customize it. */
|
|
88
91
|
include?: string | string[];
|
package/lib/bin/index.js
CHANGED
|
@@ -17,13 +17,15 @@ const watch_js_1 = require("../services/watch.js");
|
|
|
17
17
|
const poku_js_1 = require("../modules/essentials/poku.js");
|
|
18
18
|
const write_js_1 = require("../services/write.js");
|
|
19
19
|
const options_js_1 = require("../parsers/options.js");
|
|
20
|
+
const cpus_js_1 = require("../polyfills/cpus.js");
|
|
20
21
|
(async () => {
|
|
21
22
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
22
23
|
const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');
|
|
23
24
|
const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
|
|
24
25
|
const dirs = (() => {
|
|
25
26
|
var _a;
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
const includeArg = (0, get_arg_js_1.getArg)('include');
|
|
27
29
|
if (includeArg !== undefined) {
|
|
28
30
|
return includeArg.split(',');
|
|
29
31
|
}
|
|
@@ -37,11 +39,13 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
37
39
|
const killPort = (0, get_arg_js_1.getArg)('kill-port');
|
|
38
40
|
const killRange = (0, get_arg_js_1.getArg)('kill-range');
|
|
39
41
|
const killPID = (0, get_arg_js_1.getArg)('kill-pid');
|
|
42
|
+
|
|
40
43
|
const denoAllow = (_c = (0, get_arg_js_1.argToArray)('deno-allow')) !== null && _c !== void 0 ? _c : (_d = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _d === void 0 ? void 0 : _d.allow;
|
|
41
44
|
const denoDeny = (_e = (0, get_arg_js_1.argToArray)('deno-deny')) !== null && _e !== void 0 ? _e : (_f = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _f === void 0 ? void 0 : _f.deny;
|
|
42
45
|
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
46
|
(0, get_arg_js_1.hasArg)('deno-cjs') ||
|
|
44
47
|
((_h = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _h === void 0 ? void 0 : _h.cjs);
|
|
48
|
+
|
|
45
49
|
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
50
|
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
51
|
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);
|
|
@@ -55,7 +59,11 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
55
59
|
const value = Number((0, get_arg_js_1.getArg)('concurrency'));
|
|
56
60
|
return Number.isNaN(value) ? defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.concurrency : value;
|
|
57
61
|
})();
|
|
62
|
+
if (dirs.length === 1) {
|
|
63
|
+
files_js_1.states.isSinglePath = true;
|
|
64
|
+
}
|
|
58
65
|
const tasks = [];
|
|
66
|
+
|
|
59
67
|
if (killPort || ((_j = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _j === void 0 ? void 0 : _j.port)) {
|
|
60
68
|
const ports = (killPort === null || killPort === void 0 ? void 0 : killPort.split(',').map(Number)) || ((_k = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _k === void 0 ? void 0 : _k.port) || [];
|
|
61
69
|
tasks.push(kill_js_1.kill.port(ports));
|
|
@@ -75,11 +83,13 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
75
83
|
const PIDs = (killPID === null || killPID === void 0 ? void 0 : killPID.split(',').map(Number)) || ((_q = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _q === void 0 ? void 0 : _q.pid) || [];
|
|
76
84
|
tasks.push(kill_js_1.kill.pid(PIDs));
|
|
77
85
|
}
|
|
86
|
+
|
|
78
87
|
if (hasEnvFile || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile)) {
|
|
79
88
|
const envFilePath = (_r = (0, get_arg_js_1.getArg)('env-file')) !== null && _r !== void 0 ? _r : defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile;
|
|
80
89
|
tasks.push((0, env_js_1.envFile)(envFilePath));
|
|
81
90
|
}
|
|
82
91
|
const options = {
|
|
92
|
+
|
|
83
93
|
platform: (0, get_runtime_js_1.platformIsValid)(platform)
|
|
84
94
|
? platform
|
|
85
95
|
: (0, get_arg_js_1.hasArg)('node')
|
|
@@ -120,6 +130,7 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
120
130
|
const executing = new Set();
|
|
121
131
|
const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
|
|
122
132
|
let isRunning = false;
|
|
133
|
+
|
|
123
134
|
const listenStdin = (input) => {
|
|
124
135
|
if (isRunning || executing.size > 0) {
|
|
125
136
|
return;
|
|
@@ -133,6 +144,7 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
133
144
|
startTests();
|
|
134
145
|
}
|
|
135
146
|
};
|
|
147
|
+
|
|
136
148
|
const resultsClear = () => {
|
|
137
149
|
files_js_1.fileResults.success.clear();
|
|
138
150
|
files_js_1.fileResults.fail.clear();
|
|
@@ -146,6 +158,7 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
146
158
|
(0, poku_js_1.poku)(dirs, options)
|
|
147
159
|
.then(() => {
|
|
148
160
|
if (watchMode) {
|
|
161
|
+
|
|
149
162
|
node_process_1.default.stdin.removeListener('data', listenStdin);
|
|
150
163
|
node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
|
|
151
164
|
resultsClear();
|
|
@@ -163,7 +176,10 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
163
176
|
if (!tests) {
|
|
164
177
|
return;
|
|
165
178
|
}
|
|
166
|
-
(0, poku_js_1.poku)(Array.from(tests),
|
|
179
|
+
(0, poku_js_1.poku)(Array.from(tests), {
|
|
180
|
+
...options,
|
|
181
|
+
concurrency: concurrency !== null && concurrency !== void 0 ? concurrency : Math.max(Math.floor((0, cpus_js_1.availableParallelism)() / 2), 1),
|
|
182
|
+
}).then(() => {
|
|
167
183
|
setTimeout(() => {
|
|
168
184
|
executing.delete(filePath);
|
|
169
185
|
}, interval);
|
|
@@ -192,6 +208,7 @@ const options_js_1 = require("../parsers/options.js");
|
|
|
192
208
|
}
|
|
193
209
|
write_js_1.Write.hr();
|
|
194
210
|
write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
|
|
211
|
+
|
|
195
212
|
node_process_1.default.stdin.setEncoding('utf-8');
|
|
196
213
|
node_process_1.default.stdin.on('data', listenStdin);
|
|
197
214
|
}
|
package/lib/configs/files.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FileResults } from '../@types/list-files.js';
|
|
2
|
-
import type { FinalResults } from '../@types/poku.js';
|
|
2
|
+
import type { FinalResults, States } from '../@types/poku.js';
|
|
3
|
+
export declare const states: States;
|
|
3
4
|
export declare const fileResults: FileResults;
|
|
4
5
|
export declare const finalResults: FinalResults;
|
package/lib/configs/files.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.finalResults = exports.fileResults = void 0;
|
|
3
|
+
exports.finalResults = exports.fileResults = exports.states = void 0;
|
|
4
|
+
exports.states = {};
|
|
4
5
|
exports.fileResults = {
|
|
5
6
|
success: new Map(),
|
|
6
7
|
fail: new Map(),
|
package/lib/configs/poku.d.ts
CHANGED
package/lib/configs/poku.js
CHANGED
|
@@ -4,8 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.assert = void 0;
|
|
7
|
-
/* c8 ignore next */ // ?
|
|
8
7
|
const node_assert_1 = __importDefault(require("assert"));
|
|
9
8
|
const assert_js_1 = require("../../services/assert.js");
|
|
10
|
-
/* c8 ignore next */ // ?
|
|
11
9
|
exports.assert = (0, assert_js_1.createAssert)(node_assert_1.default);
|
|
@@ -12,22 +12,19 @@ const exit_js_1 = require("../helpers/exit.js");
|
|
|
12
12
|
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
|
-
|
|
16
|
-
/* c8 ignore next 3 */
|
|
15
|
+
|
|
17
16
|
const onSigint = () => {
|
|
18
17
|
node_process_1.default.stdout.write('\u001B[?25h');
|
|
19
18
|
};
|
|
20
19
|
exports.onSigint = onSigint;
|
|
21
|
-
/* c8 ignore next */
|
|
22
20
|
node_process_1.default.once('SIGINT', exports.onSigint);
|
|
23
21
|
async function poku(targetPaths, configs) {
|
|
24
22
|
let code = 0;
|
|
25
23
|
files_js_1.finalResults.started = new Date();
|
|
26
24
|
const start = node_process_1.default.hrtime();
|
|
27
|
-
const
|
|
28
|
-
const dirs = prepareDirs.length > 0 ? prepareDirs : ['.'];
|
|
25
|
+
const dirs = Array.prototype.concat(targetPaths);
|
|
29
26
|
const showLogs = !(0, output_js_1.isQuiet)(configs);
|
|
30
|
-
|
|
27
|
+
|
|
31
28
|
if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) {
|
|
32
29
|
for (const dir of dirs) {
|
|
33
30
|
const result = await (0, run_tests_js_1.runTests)(dir, configs);
|
|
@@ -44,10 +41,10 @@ async function poku(targetPaths, configs) {
|
|
|
44
41
|
const end = node_process_1.default.hrtime(start);
|
|
45
42
|
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
|
|
46
43
|
files_js_1.finalResults.time = total;
|
|
44
|
+
showLogs && (0, format_js_1.showTestResults)();
|
|
47
45
|
(0, exit_js_1.exit)(code, configs === null || configs === void 0 ? void 0 : configs.quiet);
|
|
48
|
-
return;
|
|
49
46
|
}
|
|
50
|
-
|
|
47
|
+
|
|
51
48
|
if (showLogs) {
|
|
52
49
|
write_js_1.Write.hr();
|
|
53
50
|
write_js_1.Write.log(`${(0, format_js_1.format)('Running the Test Suite in Parallel').bold()}\n`);
|
|
@@ -72,17 +69,7 @@ async function poku(targetPaths, configs) {
|
|
|
72
69
|
const total = (end[0] * 1e3 + end[1] / 1e6).toFixed(6);
|
|
73
70
|
files_js_1.finalResults.time = total;
|
|
74
71
|
}
|
|
75
|
-
showLogs &&
|
|
76
|
-
if (showLogs && files_js_1.fileResults.success.size > 0) {
|
|
77
|
-
write_js_1.Write.log(Array.from(files_js_1.fileResults.success)
|
|
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()}`)
|
|
79
|
-
.join('\n'));
|
|
80
|
-
}
|
|
81
|
-
if (showLogs && files_js_1.fileResults.fail.size > 0) {
|
|
82
|
-
write_js_1.Write.log(Array.from(files_js_1.fileResults.fail)
|
|
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()}`)
|
|
84
|
-
.join('\n'));
|
|
85
|
-
}
|
|
72
|
+
showLogs && (0, format_js_1.showTestResults)();
|
|
86
73
|
if (configs === null || configs === void 0 ? void 0 : configs.noExit) {
|
|
87
74
|
return code;
|
|
88
75
|
}
|
|
@@ -4,8 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.strict = void 0;
|
|
7
|
-
/* c8 ignore next */ // ?
|
|
8
7
|
const strict_1 = __importDefault(require("assert/strict"));
|
|
9
8
|
const assert_js_1 = require("../../services/assert.js");
|
|
10
|
-
/* c8 ignore next */ // ?
|
|
11
9
|
exports.strict = (0, assert_js_1.createAssert)(strict_1.default);
|
|
@@ -6,5 +6,4 @@ const container_js_1 = require("../../services/container.js");
|
|
|
6
6
|
const dockerfile = (configs) => new container_js_1.DockerContainer(configs);
|
|
7
7
|
/** A minimal API to assist tests that require containers or tests that run inside containers using a **docker-compose.yml**. */
|
|
8
8
|
const compose = (configs) => new container_js_1.DockerCompose(configs);
|
|
9
|
-
/* c8 ignore next */ // ?
|
|
10
9
|
exports.docker = { dockerfile, compose };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { DescribeOptions } from '../../@types/describe.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare
|
|
2
|
+
declare function describeCore(title: string, cb: () => Promise<unknown>): Promise<void>;
|
|
3
|
+
declare function describeCore(title: string, cb: () => unknown): void;
|
|
4
|
+
declare function describeCore(cb: () => Promise<unknown>): Promise<void>;
|
|
5
|
+
declare function describeCore(cb: () => unknown): unknown;
|
|
6
|
+
declare function describeCore(title: string, options?: DescribeOptions): void;
|
|
7
|
+
export declare const describe: typeof describeCore & {
|
|
8
|
+
todo: (message: string, _cb?: () => unknown) => void;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.describe =
|
|
3
|
+
exports.describe = void 0;
|
|
4
4
|
const node_process_1 = require("process");
|
|
5
5
|
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
|
-
|
|
9
|
-
async function
|
|
8
|
+
const todo_js_1 = require("./it/todo.js");
|
|
9
|
+
async function describeCore(arg1, arg2) {
|
|
10
10
|
let title;
|
|
11
11
|
let cb;
|
|
12
12
|
let options;
|
|
@@ -28,7 +28,7 @@ async function describe(arg1, arg2) {
|
|
|
28
28
|
if (title) {
|
|
29
29
|
indentation_js_1.indentation.hasDescribe = true;
|
|
30
30
|
const { background, icon } = options || {};
|
|
31
|
-
const message = `${cb ? (0, format_js_1.format)('◌').dim() : 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()
|
|
31
|
+
const message = `${cb ? (0, format_js_1.format)('◌').dim() : 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
32
|
const noBackground = !background;
|
|
33
33
|
if (noBackground) {
|
|
34
34
|
write_js_1.Write.log((0, format_js_1.format)(message).bold());
|
|
@@ -52,3 +52,6 @@ async function describe(arg1, arg2) {
|
|
|
52
52
|
write_js_1.Write.log(`${(0, format_js_1.format)(`● ${title}`).success().bold()} ${(0, format_js_1.format)(`› ${total}ms`).success().dim()}`);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
exports.describe = Object.assign(describeCore, {
|
|
56
|
+
todo: todo_js_1.todo,
|
|
57
|
+
});
|
|
@@ -8,7 +8,7 @@ import type { Control, EachOptions } from '../../@types/each.js';
|
|
|
8
8
|
* import { beforeEach } from 'poku';
|
|
9
9
|
*
|
|
10
10
|
* const before = beforeEach(() => {
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
* };
|
|
13
13
|
*
|
|
14
14
|
* before.pause();
|
|
@@ -26,7 +26,7 @@ export declare const beforeEach: (callback: () => unknown, options?: EachOptions
|
|
|
26
26
|
* import { afterEach } from 'poku';
|
|
27
27
|
*
|
|
28
28
|
* const after = afterEach(() => {
|
|
29
|
-
*
|
|
29
|
+
*
|
|
30
30
|
* };
|
|
31
31
|
*
|
|
32
32
|
* after.pause();
|
|
@@ -11,7 +11,7 @@ const each_js_1 = require("../../configs/each.js");
|
|
|
11
11
|
* import { beforeEach } from 'poku';
|
|
12
12
|
*
|
|
13
13
|
* const before = beforeEach(() => {
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* };
|
|
16
16
|
*
|
|
17
17
|
* before.pause();
|
|
@@ -47,7 +47,7 @@ exports.beforeEach = beforeEach;
|
|
|
47
47
|
* import { afterEach } from 'poku';
|
|
48
48
|
*
|
|
49
49
|
* const after = afterEach(() => {
|
|
50
|
-
*
|
|
50
|
+
*
|
|
51
51
|
* };
|
|
52
52
|
*
|
|
53
53
|
* after.pause();
|
|
@@ -55,7 +55,6 @@ exports.beforeEach = beforeEach;
|
|
|
55
55
|
* after.reset();
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
-
/* c8 ignore next */ // ?
|
|
59
58
|
const afterEach = (callback) => {
|
|
60
59
|
each_js_1.each.after.cb = () => {
|
|
61
60
|
if (each_js_1.each.after.status) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.envFile = void 0;
|
|
4
|
-
/* c8 ignore start */ // ?
|
|
5
4
|
const fs_js_1 = require("../../polyfills/fs.js");
|
|
6
5
|
const list_files_js_1 = require("./list-files.js");
|
|
7
6
|
const env_js_1 = require("../../services/env.js");
|
|
@@ -10,7 +9,6 @@ const regex = {
|
|
|
10
9
|
};
|
|
11
10
|
/** Reads an environment file and sets the environment variables. */
|
|
12
11
|
const envFile = async (filePath = '.env') => {
|
|
13
|
-
/* c8 ignore stop */
|
|
14
12
|
const mapEnv = new Map();
|
|
15
13
|
const env = await (0, fs_js_1.readFile)((0, list_files_js_1.sanitizePath)(filePath), 'utf8');
|
|
16
14
|
const lines = env
|
|
@@ -12,6 +12,30 @@ const files_js_1 = require("../../configs/files.js");
|
|
|
12
12
|
const time_js_1 = require("../../parsers/time.js");
|
|
13
13
|
const exit = (code, quiet) => {
|
|
14
14
|
const isPoku = poku_js_1.results.success > 0 || poku_js_1.results.fail > 0;
|
|
15
|
+
const success = ` PASS › ${poku_js_1.results.success - poku_js_1.results.skip || 0} `;
|
|
16
|
+
const failure = ` FAIL › ${poku_js_1.results.fail} `;
|
|
17
|
+
const skips = ` SKIP › ${poku_js_1.results.skip} `;
|
|
18
|
+
const plans = ` TODO › ${poku_js_1.results.todo} `;
|
|
19
|
+
const inline = poku_js_1.results.skip === 0 || poku_js_1.results.todo === 0;
|
|
20
|
+
let message = '';
|
|
21
|
+
if (inline) {
|
|
22
|
+
message += `${(0, format_js_1.format)(success).bg('green')} ${(0, format_js_1.format)(failure).bg(poku_js_1.results.fail === 0 ? 'grey' : 'brightRed')}`;
|
|
23
|
+
if (poku_js_1.results.skip) {
|
|
24
|
+
message += ` ${(0, format_js_1.format)(skips).bg('brightBlue')}`;
|
|
25
|
+
}
|
|
26
|
+
if (poku_js_1.results.todo) {
|
|
27
|
+
message += ` ${(0, format_js_1.format)(plans).bg('brightBlue')}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
message += `${(0, format_js_1.format)(success).success().bold()}\n`;
|
|
32
|
+
message +=
|
|
33
|
+
poku_js_1.results.fail === 0
|
|
34
|
+
? (0, format_js_1.format)(`${failure}\n`).bold()
|
|
35
|
+
: `${(0, format_js_1.format)(failure).fail().bold()}\n`;
|
|
36
|
+
message += `${(0, format_js_1.format)(skips).info().bold()}\n`;
|
|
37
|
+
message += `${(0, format_js_1.format)(plans).info().bold()}`;
|
|
38
|
+
}
|
|
15
39
|
!quiet &&
|
|
16
40
|
node_process_1.default.on('exit', (code) => {
|
|
17
41
|
if (isPoku) {
|
|
@@ -20,7 +44,7 @@ const exit = (code, quiet) => {
|
|
|
20
44
|
write_js_1.Write.log(` ${(0, format_js_1.format)('Duration ›').dim()} ${(0, format_js_1.format)(`${files_js_1.finalResults.time}ms`).bold().dim()} ${(0, format_js_1.format)(`(±${(0, time_js_1.parseTimeToSecs)(files_js_1.finalResults.time)} seconds)`).dim()}`);
|
|
21
45
|
write_js_1.Write.log(` ${(0, format_js_1.format)(`Test Files › ${(0, format_js_1.format)(String(files_js_1.fileResults.success.size + files_js_1.fileResults.fail.size)).bold()}`).dim()}`);
|
|
22
46
|
write_js_1.Write.hr();
|
|
23
|
-
write_js_1.Write.log(
|
|
47
|
+
write_js_1.Write.log(message);
|
|
24
48
|
write_js_1.Write.hr();
|
|
25
49
|
}
|
|
26
50
|
write_js_1.Write.log(`${(0, format_js_1.format)('Exited with code').dim()} ${(0, format_js_1.format)(String(code)).bold()[code === 0 ? 'success' : 'fail']()}\n`);
|
|
@@ -28,10 +52,12 @@ const exit = (code, quiet) => {
|
|
|
28
52
|
node_process_1.default.exit(code === 0 ? 0 : 1);
|
|
29
53
|
};
|
|
30
54
|
exports.exit = exit;
|
|
55
|
+
|
|
31
56
|
node_process_1.default.on('unhandledRejection', (reason) => {
|
|
32
57
|
console.error('unhandledRejection', reason);
|
|
33
58
|
node_process_1.default.exit(1);
|
|
34
59
|
});
|
|
60
|
+
|
|
35
61
|
node_process_1.default.on('uncaughtException', (err) => {
|
|
36
62
|
console.error('uncaughtException', err);
|
|
37
63
|
node_process_1.default.exit(1);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare function itCore(message: string, cb: () => Promise<unknown>): Promise<void>;
|
|
2
|
+
declare function itCore(message: string, cb: () => unknown): void;
|
|
3
|
+
declare function itCore(cb: () => Promise<unknown>): Promise<void>;
|
|
4
|
+
declare function itCore(cb: () => unknown): void;
|
|
5
|
+
export declare const it: typeof itCore & {
|
|
6
|
+
todo: (message: string, _cb?: () => unknown) => void;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.it =
|
|
4
|
-
/* c8 ignore next */ // ?
|
|
3
|
+
exports.it = void 0;
|
|
5
4
|
const node_process_1 = require("process");
|
|
6
|
-
const each_js_1 = require("
|
|
7
|
-
const indentation_js_1 = require("
|
|
8
|
-
const format_js_1 = require("
|
|
9
|
-
const write_js_1 = require("
|
|
10
|
-
|
|
11
|
-
async function
|
|
5
|
+
const each_js_1 = require("../../../configs/each.js");
|
|
6
|
+
const indentation_js_1 = require("../../../configs/indentation.js");
|
|
7
|
+
const format_js_1 = require("../../../services/format.js");
|
|
8
|
+
const write_js_1 = require("../../../services/write.js");
|
|
9
|
+
const todo_js_1 = require("./todo.js");
|
|
10
|
+
async function itCore(...args) {
|
|
12
11
|
try {
|
|
13
12
|
let message;
|
|
14
13
|
let cb;
|
|
@@ -23,7 +22,7 @@ async function it(...args) {
|
|
|
23
22
|
}
|
|
24
23
|
if (message) {
|
|
25
24
|
indentation_js_1.indentation.hasItOrTest = true;
|
|
26
|
-
write_js_1.Write.log(isPoku
|
|
25
|
+
write_js_1.Write.log(isPoku
|
|
27
26
|
? `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`◌ ${message} › ${(0, format_js_1.format)(`${FILE}`).italic().gray()}`).dim()}`
|
|
28
27
|
: `${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`◌ ${message}`).dim()}`);
|
|
29
28
|
}
|
|
@@ -62,3 +61,6 @@ async function it(...args) {
|
|
|
62
61
|
throw error;
|
|
63
62
|
}
|
|
64
63
|
}
|
|
64
|
+
exports.it = Object.assign(itCore, {
|
|
65
|
+
todo: todo_js_1.todo,
|
|
66
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const todo: (message: string, _cb?: () => unknown) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.todo = void 0;
|
|
4
|
+
const write_js_1 = require("../../../services/write.js");
|
|
5
|
+
const indentation_js_1 = require("../../../configs/indentation.js");
|
|
6
|
+
const format_js_1 = require("../../../services/format.js");
|
|
7
|
+
const todo = (message, _cb) => {
|
|
8
|
+
write_js_1.Write.log(`${indentation_js_1.indentation.hasDescribe ? ' ' : ''}${(0, format_js_1.format)(`● ${message}`).cyan().bold()}`);
|
|
9
|
+
};
|
|
10
|
+
exports.todo = todo;
|
|
@@ -5,6 +5,7 @@ exports.listFiles = exports.getAllFiles = exports.escapeRegExp = exports.isFile
|
|
|
5
5
|
const node_process_1 = require("process");
|
|
6
6
|
const node_path_1 = require("path");
|
|
7
7
|
const fs_js_1 = require("../../polyfills/fs.js");
|
|
8
|
+
const files_js_1 = require("../../configs/files.js");
|
|
8
9
|
const regex = {
|
|
9
10
|
sep: /[/\\]+/g,
|
|
10
11
|
pathLevel: /(\.\.(\/|\\|$))+/g,
|
|
@@ -31,7 +32,14 @@ const envFilter = ((_a = node_process_1.env.FILTER) === null || _a === void 0 ?
|
|
|
31
32
|
? new RegExp((0, exports.escapeRegExp)(node_process_1.env.FILTER), 'i')
|
|
32
33
|
: undefined;
|
|
33
34
|
const getAllFiles = async (dirPath, files = new Set(), configs) => {
|
|
34
|
-
|
|
35
|
+
let isFullPath = false;
|
|
36
|
+
const currentFiles = await (async () => {
|
|
37
|
+
if (await (0, exports.isFile)(dirPath)) {
|
|
38
|
+
isFullPath = true;
|
|
39
|
+
return Array.prototype.concat((0, exports.sanitizePath)(dirPath));
|
|
40
|
+
}
|
|
41
|
+
return await (0, fs_js_1.readdir)((0, exports.sanitizePath)(dirPath));
|
|
42
|
+
})();
|
|
35
43
|
const filter = envFilter
|
|
36
44
|
? envFilter
|
|
37
45
|
: (configs === null || configs === void 0 ? void 0 : configs.filter) instanceof RegExp
|
|
@@ -43,13 +51,15 @@ const getAllFiles = async (dirPath, files = new Set(), configs) => {
|
|
|
43
51
|
: [configs.exclude]
|
|
44
52
|
: undefined;
|
|
45
53
|
await Promise.all(currentFiles.map(async (file) => {
|
|
46
|
-
const fullPath = (0, node_path_1.join)(dirPath, file);
|
|
54
|
+
const fullPath = isFullPath ? dirPath : (0, node_path_1.join)(dirPath, file);
|
|
47
55
|
const stat = await (0, fs_js_1.stat)(fullPath);
|
|
48
|
-
/* c8 ignore next 6 */
|
|
49
56
|
if (fullPath.indexOf('node_modules') !== -1 ||
|
|
50
|
-
fullPath.indexOf('.git')
|
|
57
|
+
fullPath.indexOf('.git/') !== -1) {
|
|
51
58
|
return;
|
|
52
59
|
}
|
|
60
|
+
if (isFullPath && (files_js_1.states === null || files_js_1.states === void 0 ? void 0 : files_js_1.states.isSinglePath)) {
|
|
61
|
+
return files.add(fullPath);
|
|
62
|
+
}
|
|
53
63
|
if (exclude) {
|
|
54
64
|
for (const pattern of exclude) {
|
|
55
65
|
if (pattern.test(fullPath)) {
|
|
@@ -67,6 +77,5 @@ const getAllFiles = async (dirPath, files = new Set(), configs) => {
|
|
|
67
77
|
return files;
|
|
68
78
|
};
|
|
69
79
|
exports.getAllFiles = getAllFiles;
|
|
70
|
-
/* c8 ignore next */ // ?
|
|
71
80
|
const listFiles = async (targetDir, configs) => Array.from(await (0, exports.getAllFiles)((0, exports.sanitizePath)(targetDir), new Set(), configs));
|
|
72
81
|
exports.listFiles = listFiles;
|
|
@@ -4,13 +4,13 @@ exports.skip = void 0;
|
|
|
4
4
|
const node_process_1 = require("process");
|
|
5
5
|
const write_js_1 = require("../../services/write.js");
|
|
6
6
|
const format_js_1 = require("../../services/format.js");
|
|
7
|
-
const skip = (message) => {
|
|
7
|
+
const skip = (message = 'Skipping') => {
|
|
8
8
|
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;
|
|
9
9
|
const FILE = node_process_1.env.FILE;
|
|
10
10
|
if (message) {
|
|
11
11
|
write_js_1.Write.log((0, format_js_1.format)(isPoku
|
|
12
|
-
?
|
|
13
|
-
:
|
|
12
|
+
? `◯ ${message} ${(0, format_js_1.format)('›').dim()} ${(0, format_js_1.format)(`${FILE}`).italic().gray().dim()}`
|
|
13
|
+
: `◯ ${message}`)
|
|
14
14
|
.info()
|
|
15
15
|
.bold());
|
|
16
16
|
}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const test: {
|
|
2
|
+
(message: string, cb: () => Promise<unknown>): Promise<void>;
|
|
3
|
+
(message: string, cb: () => unknown): void;
|
|
4
|
+
(cb: () => Promise<unknown>): Promise<void>;
|
|
5
|
+
(cb: () => unknown): void;
|
|
6
|
+
} & {
|
|
7
|
+
todo: (message: string, _cb?: () => unknown) => void;
|
|
8
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.test = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/* c8 ignore next */ // ?
|
|
7
|
-
exports.test = it_js_1.it;
|
|
4
|
+
const core_js_1 = require("./it/core.js");
|
|
5
|
+
exports.test = core_js_1.it;
|