poku 2.2.4 → 2.4.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 CHANGED
@@ -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
- # Deno
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
- - \>=**4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0)
235
- - \>=**3x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v1.6.0)
236
- - \>=**1x** faster than [**Mocha**](https://github.com/mochajs/mocha) (v10.4.0) + [**Chai**](https://github.com/chaijs/chai) (v5.1.1)
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/bin/index.js CHANGED
@@ -1,10 +1,6 @@
1
1
  #! /usr/bin/env node
2
2
  "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
3
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const node_process_1 = __importDefault(require("process"));
8
4
  const list_files_js_1 = require("../modules/helpers/list-files.js");
9
5
  const get_arg_js_1 = require("../parsers/get-arg.js");
10
6
  const files_js_1 = require("../configs/files.js");
@@ -12,18 +8,22 @@ const get_runtime_js_1 = require("../parsers/get-runtime.js");
12
8
  const format_js_1 = require("../services/format.js");
13
9
  const kill_js_1 = require("../modules/helpers/kill.js");
14
10
  const env_js_1 = require("../modules/helpers/env.js");
15
- const map_tests_js_1 = require("../services/map-tests.js");
16
- const watch_js_1 = require("../services/watch.js");
17
11
  const poku_js_1 = require("../modules/essentials/poku.js");
18
12
  const write_js_1 = require("../services/write.js");
19
13
  const options_js_1 = require("../parsers/options.js");
20
14
  (async () => {
21
15
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
16
+ if ((0, get_arg_js_1.hasArg)('version') || (0, get_arg_js_1.hasArg)('v', '-')) {
17
+ const { VERSION } = require('../configs/poku.js');
18
+ write_js_1.Write.log(VERSION);
19
+ return;
20
+ }
22
21
  const configFile = (0, get_arg_js_1.getArg)('config') || (0, get_arg_js_1.getArg)('c', '-');
23
22
  const defaultConfigs = await (0, options_js_1.getConfigs)(configFile);
24
23
  const dirs = (() => {
25
24
  var _a;
26
- const includeArg = (0, get_arg_js_1.getArg)('include');
25
+
26
+ const includeArg = (0, get_arg_js_1.getArg)('include');
27
27
  if (includeArg !== undefined) {
28
28
  return includeArg.split(',');
29
29
  }
@@ -37,11 +37,13 @@ const options_js_1 = require("../parsers/options.js");
37
37
  const killPort = (0, get_arg_js_1.getArg)('kill-port');
38
38
  const killRange = (0, get_arg_js_1.getArg)('kill-range');
39
39
  const killPID = (0, get_arg_js_1.getArg)('kill-pid');
40
+
40
41
  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
42
  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
43
  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
44
  (0, get_arg_js_1.hasArg)('deno-cjs') ||
44
45
  ((_h = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.deno) === null || _h === void 0 ? void 0 : _h.cjs);
46
+
45
47
  const parallel = (0, get_arg_js_1.hasArg)('parallel') || (0, get_arg_js_1.hasArg)('p', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.parallel);
46
48
  const quiet = (0, get_arg_js_1.hasArg)('quiet') || (0, get_arg_js_1.hasArg)('q', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.quiet);
47
49
  const debug = (0, get_arg_js_1.hasArg)('debug') || (0, get_arg_js_1.hasArg)('d', '-') || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.debug);
@@ -58,7 +60,29 @@ const options_js_1 = require("../parsers/options.js");
58
60
  if (dirs.length === 1) {
59
61
  files_js_1.states.isSinglePath = true;
60
62
  }
63
+ if ((0, get_arg_js_1.hasArg)('list-files')) {
64
+ const { listFiles } = require('../modules/helpers/list-files.js');
65
+ let total = 0;
66
+ write_js_1.Write.hr();
67
+ for (const dir of dirs) {
68
+ const files = await listFiles(dir, {
69
+ filter: typeof filter === 'string'
70
+ ? new RegExp((0, list_files_js_1.escapeRegExp)(filter))
71
+ : filter,
72
+ exclude: typeof exclude === 'string'
73
+ ? new RegExp((0, list_files_js_1.escapeRegExp)(exclude))
74
+ : exclude,
75
+ });
76
+ total += files.length;
77
+ write_js_1.Write.log(files.map((file) => `${(0, format_js_1.format)('-').dim()} ${file}`).join('\n'));
78
+ }
79
+ write_js_1.Write.hr();
80
+ write_js_1.Write.log(`Total test files: ${(0, format_js_1.format)(String(total)).bold()}`);
81
+ write_js_1.Write.hr();
82
+ return;
83
+ }
61
84
  const tasks = [];
85
+
62
86
  if (killPort || ((_j = defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.kill) === null || _j === void 0 ? void 0 : _j.port)) {
63
87
  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) || [];
64
88
  tasks.push(kill_js_1.kill.port(ports));
@@ -78,11 +102,13 @@ const options_js_1 = require("../parsers/options.js");
78
102
  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) || [];
79
103
  tasks.push(kill_js_1.kill.pid(PIDs));
80
104
  }
105
+
81
106
  if (hasEnvFile || (defaultConfigs === null || defaultConfigs === void 0 ? void 0 : defaultConfigs.envFile)) {
82
107
  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;
83
108
  tasks.push((0, env_js_1.envFile)(envFilePath));
84
109
  }
85
110
  const options = {
111
+
86
112
  platform: (0, get_runtime_js_1.platformIsValid)(platform)
87
113
  ? platform
88
114
  : (0, get_arg_js_1.hasArg)('node')
@@ -119,90 +145,10 @@ const options_js_1 = require("../parsers/options.js");
119
145
  write_js_1.Write.log(`${(0, format_js_1.format)('…').info().italic()} ${(0, format_js_1.format)('Options').bold()}`);
120
146
  console.dir(options, { depth: null, colors: true });
121
147
  }
122
- const watchers = new Set();
123
- const executing = new Set();
124
- const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
125
- let isRunning = false;
126
- const listenStdin = (input) => {
127
- if (isRunning || executing.size > 0) {
128
- return;
129
- }
130
- if (String(input).trim() === 'rs') {
131
- for (const watcher of watchers) {
132
- watcher.stop();
133
- }
134
- watchers.clear();
135
- resultsClear();
136
- startTests();
137
- }
138
- };
139
- const resultsClear = () => {
140
- files_js_1.fileResults.success.clear();
141
- files_js_1.fileResults.fail.clear();
142
- };
143
- const startTests = () => {
144
- if (isRunning || executing.size > 0) {
145
- return;
146
- }
147
- isRunning = true;
148
- Promise.all(tasks).then(() => {
149
- (0, poku_js_1.poku)(dirs, options)
150
- .then(() => {
151
- if (watchMode) {
152
- node_process_1.default.stdin.removeListener('data', listenStdin);
153
- node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
154
- resultsClear();
155
- (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude).then((mappedTests) => {
156
- for (const mappedTest of Array.from(mappedTests.keys())) {
157
- const currentWatcher = (0, watch_js_1.watch)(mappedTest, (file, event) => {
158
- if (event === 'change') {
159
- const filePath = (0, map_tests_js_1.normalizePath)(file);
160
- if (executing.has(filePath)) {
161
- return;
162
- }
163
- executing.add(filePath);
164
- resultsClear();
165
- const tests = mappedTests.get(filePath);
166
- if (!tests) {
167
- return;
168
- }
169
- (0, poku_js_1.poku)(Array.from(tests), options).then(() => {
170
- setTimeout(() => {
171
- executing.delete(filePath);
172
- }, interval);
173
- });
174
- }
175
- });
176
- currentWatcher.then((watcher) => watchers.add(watcher));
177
- }
178
- });
179
- for (const dir of dirs) {
180
- const currentWatcher = (0, watch_js_1.watch)(dir, (file, event) => {
181
- if (event === 'change') {
182
- if (executing.has(file)) {
183
- return;
184
- }
185
- executing.add(file);
186
- resultsClear();
187
- (0, poku_js_1.poku)(file, options).then(() => {
188
- setTimeout(() => {
189
- executing.delete(file);
190
- }, interval);
191
- });
192
- }
193
- });
194
- currentWatcher.then((watcher) => watchers.add(watcher));
195
- }
196
- write_js_1.Write.hr();
197
- write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
198
- node_process_1.default.stdin.setEncoding('utf-8');
199
- node_process_1.default.stdin.on('data', listenStdin);
200
- }
201
- })
202
- .finally(() => {
203
- isRunning = false;
204
- });
205
- });
206
- };
207
- startTests();
148
+ await Promise.all(tasks);
149
+ await (0, poku_js_1.poku)(dirs, options);
150
+ if (watchMode) {
151
+ const { startWatch } = require('./watch.js');
152
+ await startWatch(dirs, options);
153
+ }
208
154
  })();
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.startWatch = void 0;
7
+ const map_tests_js_1 = require("../services/map-tests.js");
8
+ const watch_js_1 = require("../services/watch.js");
9
+ const poku_js_1 = require("../modules/essentials/poku.js");
10
+ const write_js_1 = require("../services/write.js");
11
+ const node_process_1 = __importDefault(require("process"));
12
+ const format_js_1 = require("../services/format.js");
13
+ const get_arg_js_1 = require("../parsers/get-arg.js");
14
+ const files_js_1 = require("../configs/files.js");
15
+ const cpus_js_1 = require("../polyfills/cpus.js");
16
+ const startWatch = async (dirs, options) => {
17
+ let isRunning = false;
18
+ const watchers = new Set();
19
+ const executing = new Set();
20
+ const interval = Number((0, get_arg_js_1.getArg)('watch-interval')) || 1500;
21
+ const setIsRunning = (value) => {
22
+ isRunning = value;
23
+ };
24
+ const resultsClear = () => {
25
+ files_js_1.fileResults.success.clear();
26
+ files_js_1.fileResults.fail.clear();
27
+ };
28
+ const listenStdin = async (input) => {
29
+ if (isRunning || executing.size > 0) {
30
+ return;
31
+ }
32
+ if (String(input).trim() === 'rs') {
33
+ for (const watcher of watchers) {
34
+ watcher.stop();
35
+ }
36
+ watchers.clear();
37
+ resultsClear();
38
+ await (0, poku_js_1.poku)(dirs, options);
39
+ }
40
+ };
41
+ node_process_1.default.stdin.removeListener('data', listenStdin);
42
+ node_process_1.default.removeListener('SIGINT', poku_js_1.onSigint);
43
+ resultsClear();
44
+ const mappedTests = await (0, map_tests_js_1.mapTests)('.', dirs, options.filter, options.exclude);
45
+ for (const mappedTest of Array.from(mappedTests.keys())) {
46
+ const currentWatcher = (0, watch_js_1.watch)(mappedTest, async (file, event) => {
47
+ var _a;
48
+ if (event === 'change') {
49
+ const filePath = (0, map_tests_js_1.normalizePath)(file);
50
+ if (executing.has(filePath) || isRunning || executing.size > 0) {
51
+ return;
52
+ }
53
+ setIsRunning(true);
54
+ executing.add(filePath);
55
+ resultsClear();
56
+ const tests = mappedTests.get(filePath);
57
+ if (!tests) {
58
+ return;
59
+ }
60
+ await (0, poku_js_1.poku)(Array.from(tests), {
61
+ ...options,
62
+ concurrency: (_a = options.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0, cpus_js_1.availableParallelism)() / 2), 1),
63
+ });
64
+ setTimeout(() => {
65
+ executing.delete(filePath);
66
+ setIsRunning(false);
67
+ }, interval);
68
+ }
69
+ });
70
+ currentWatcher.then((watcher) => watchers.add(watcher));
71
+ }
72
+ for (const dir of dirs) {
73
+ const currentWatcher = (0, watch_js_1.watch)(dir, (file, event) => {
74
+ if (event === 'change') {
75
+ if (executing.has(file) || isRunning || executing.size > 0) {
76
+ return;
77
+ }
78
+ setIsRunning(true);
79
+ executing.add(file);
80
+ resultsClear();
81
+ (0, poku_js_1.poku)(file, options).then(() => {
82
+ setTimeout(() => {
83
+ executing.delete(file);
84
+ setIsRunning(false);
85
+ }, interval);
86
+ });
87
+ }
88
+ });
89
+ currentWatcher.then((watcher) => watchers.add(watcher));
90
+ }
91
+ write_js_1.Write.hr();
92
+ write_js_1.Write.log(`${(0, format_js_1.format)('Watching:').bold()} ${(0, format_js_1.format)(dirs.join(', ')).underline()}`);
93
+ node_process_1.default.stdin.setEncoding('utf-8');
94
+ node_process_1.default.stdin.on('data', listenStdin);
95
+ };
96
+ exports.startWatch = startWatch;
@@ -1,5 +1,7 @@
1
1
  export declare const results: {
2
2
  success: number;
3
3
  fail: number;
4
- skipped: number;
4
+ skip: number;
5
+ todo: number;
5
6
  };
7
+ export declare const VERSION = "";
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.results = void 0;
3
+ exports.VERSION = exports.results = void 0;
4
4
  exports.results = {
5
5
  success: 0,
6
6
  fail: 0,
7
- skipped: 0,
7
+ skip: 0,
8
+ todo: 0,
8
9
  };
10
+ exports.VERSION = '2.4.0';
@@ -17,14 +17,12 @@ const onSigint = () => {
17
17
  node_process_1.default.stdout.write('\u001B[?25h');
18
18
  };
19
19
  exports.onSigint = onSigint;
20
-
21
20
  node_process_1.default.once('SIGINT', exports.onSigint);
22
21
  async function poku(targetPaths, configs) {
23
22
  let code = 0;
24
23
  files_js_1.finalResults.started = new Date();
25
24
  const start = node_process_1.default.hrtime();
26
- const prepareDirs = Array.prototype.concat(targetPaths);
27
- const dirs = prepareDirs.length > 0 ? prepareDirs : ['.'];
25
+ const dirs = Array.prototype.concat(targetPaths);
28
26
  const showLogs = !(0, output_js_1.isQuiet)(configs);
29
27
 
30
28
  if (!(configs === null || configs === void 0 ? void 0 : configs.parallel)) {
@@ -45,7 +43,6 @@ async function poku(targetPaths, configs) {
45
43
  files_js_1.finalResults.time = total;
46
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) {
@@ -1,6 +1,10 @@
1
1
  import type { DescribeOptions } from '../../@types/describe.js';
2
- export declare function describe(title: string, cb: () => Promise<unknown>): Promise<void>;
3
- export declare function describe(title: string, cb: () => unknown): void;
4
- export declare function describe(cb: () => Promise<unknown>): Promise<void>;
5
- export declare function describe(cb: () => unknown): unknown;
6
- export declare function describe(title: string, options?: DescribeOptions): void;
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,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.describe = 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
- async function describe(arg1, arg2) {
8
+ const todo_js_1 = require("./it/todo.js");
9
+ async function describeCore(arg1, arg2) {
9
10
  let title;
10
11
  let cb;
11
12
  let options;
@@ -51,3 +52,6 @@ async function describe(arg1, arg2) {
51
52
  write_js_1.Write.log(`${(0, format_js_1.format)(`● ${title}`).success().bold()} ${(0, format_js_1.format)(`› ${total}ms`).success().dim()}`);
52
53
  }
53
54
  }
55
+ exports.describe = Object.assign(describeCore, {
56
+ todo: todo_js_1.todo,
57
+ });
@@ -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(`${(0, format_js_1.format)(` PASS › ${poku_js_1.results.success - poku_js_1.results.skipped} `).bg('green')} ${(0, format_js_1.format)(` FAIL › ${poku_js_1.results.fail} `).bg(poku_js_1.results.fail === 0 ? 'grey' : 'red')} ${poku_js_1.results.skipped > 0 ? (0, format_js_1.format)(` SKIPPED › ${poku_js_1.results.skipped} `).bg(poku_js_1.results.skipped === 0 ? 'grey' : 'blue') : ''}`);
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`);
@@ -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,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.it = it;
3
+ exports.it = void 0;
4
4
  const node_process_1 = require("process");
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
- async function it(...args) {
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) {
10
11
  try {
11
12
  let message;
12
13
  let cb;
@@ -60,3 +61,6 @@ async function it(...args) {
60
61
  throw error;
61
62
  }
62
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;
@@ -54,7 +54,7 @@ const getAllFiles = async (dirPath, files = new Set(), configs) => {
54
54
  const fullPath = isFullPath ? dirPath : (0, node_path_1.join)(dirPath, file);
55
55
  const stat = await (0, fs_js_1.stat)(fullPath);
56
56
  if (fullPath.indexOf('node_modules') !== -1 ||
57
- fullPath.indexOf('.git') === 0) {
57
+ fullPath.indexOf('.git/') !== -1) {
58
58
  return;
59
59
  }
60
60
  if (isFullPath && (files_js_1.states === null || files_js_1.states === void 0 ? void 0 : files_js_1.states.isSinglePath)) {
@@ -1,2 +1,2 @@
1
1
  /** By default **Poku** only shows outputs generated from itself. This helper allows you to use an alternative to `console.log` with **Poku**. */
2
- export declare const log: (message: string) => void;
2
+ export declare const log: (...args: unknown[]) => void;
@@ -1,7 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.log = void 0;
4
+ const assert_js_1 = require("../../parsers/assert.js");
4
5
  const write_js_1 = require("../../services/write.js");
5
6
  /** By default **Poku** only shows outputs generated from itself. This helper allows you to use an alternative to `console.log` with **Poku**. */
6
- const log = (message) => write_js_1.Write.log(`\x1b[0m${message}\x1b[0m`);
7
+ const log = (...args) => {
8
+ const parsedMessages = args
9
+ .map((arg) => (0, assert_js_1.parseResultType)(arg))
10
+ .join(' ')
11
+ .split('\n')
12
+ .map((line) => `\x1b[0m${line}\x1b[0m`)
13
+ .join('\n');
14
+ write_js_1.Write.log(parsedMessages);
15
+ };
7
16
  exports.log = log;
@@ -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
- ? `ℹ ${message} ${(0, format_js_1.format)('›').dim()} ${(0, format_js_1.format)(`${FILE}`).italic().gray().dim()}`
13
- : `ℹ ${message}`)
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
- import { it } from './it.js';
2
- export declare const test: typeof it;
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,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.test = void 0;
4
- const it_js_1 = require("./it.js");
5
- exports.test = it_js_1.it;
4
+ const core_js_1 = require("./it/core.js");
5
+ exports.test = core_js_1.it;
@@ -4,7 +4,7 @@ export { assert } from './essentials/assert.js';
4
4
  export { strict } from './essentials/strict.js';
5
5
  export { test } from './helpers/test.js';
6
6
  export { describe } from './helpers/describe.js';
7
- export { it } from './helpers/it.js';
7
+ export { it } from './helpers/it/core.js';
8
8
  export { envFile } from './helpers/env.js';
9
9
  export { skip } from './helpers/skip.js';
10
10
  export { beforeEach, afterEach } from './helpers/each.js';
@@ -16,6 +16,7 @@ export { getPIDs } from './helpers/get-pids.js';
16
16
  export { exit } from './helpers/exit.js';
17
17
  export { log } from './helpers/log.js';
18
18
  export { listFiles } from './helpers/list-files.js';
19
+ export { VERSION as version } from '../configs/poku.js';
19
20
  export type { Code } from '../@types/code.js';
20
21
  export type { Configs } from '../@types/poku.js';
21
22
  export type { DockerComposeConfigs, DockerfileConfigs, } from '../@types/container.js';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineConfig = exports.listFiles = exports.log = exports.exit = exports.getPIDs = exports.kill = exports.sleep = exports.waitForPort = exports.waitForExpectedResult = exports.startService = exports.startScript = exports.docker = exports.afterEach = exports.beforeEach = exports.skip = exports.envFile = exports.it = exports.describe = exports.test = exports.strict = exports.assert = exports.poku = void 0;
3
+ exports.defineConfig = exports.version = exports.listFiles = exports.log = exports.exit = exports.getPIDs = exports.kill = exports.sleep = exports.waitForPort = exports.waitForExpectedResult = exports.startService = exports.startScript = exports.docker = exports.afterEach = exports.beforeEach = exports.skip = exports.envFile = exports.it = exports.describe = exports.test = exports.strict = exports.assert = exports.poku = void 0;
4
4
  var poku_js_1 = require("./essentials/poku.js");
5
5
  Object.defineProperty(exports, "poku", { enumerable: true, get: function () { return poku_js_1.poku; } });
6
6
  var assert_js_1 = require("./essentials/assert.js");
@@ -11,8 +11,8 @@ var test_js_1 = require("./helpers/test.js");
11
11
  Object.defineProperty(exports, "test", { enumerable: true, get: function () { return test_js_1.test; } });
12
12
  var describe_js_1 = require("./helpers/describe.js");
13
13
  Object.defineProperty(exports, "describe", { enumerable: true, get: function () { return describe_js_1.describe; } });
14
- var it_js_1 = require("./helpers/it.js");
15
- Object.defineProperty(exports, "it", { enumerable: true, get: function () { return it_js_1.it; } });
14
+ var core_js_1 = require("./helpers/it/core.js");
15
+ Object.defineProperty(exports, "it", { enumerable: true, get: function () { return core_js_1.it; } });
16
16
  var env_js_1 = require("./helpers/env.js");
17
17
  Object.defineProperty(exports, "envFile", { enumerable: true, get: function () { return env_js_1.envFile; } });
18
18
  var skip_js_1 = require("./helpers/skip.js");
@@ -39,6 +39,8 @@ var log_js_1 = require("./helpers/log.js");
39
39
  Object.defineProperty(exports, "log", { enumerable: true, get: function () { return log_js_1.log; } });
40
40
  var list_files_js_1 = require("./helpers/list-files.js");
41
41
  Object.defineProperty(exports, "listFiles", { enumerable: true, get: function () { return list_files_js_1.listFiles; } });
42
+ var poku_js_2 = require("../configs/poku.js");
43
+ Object.defineProperty(exports, "version", { enumerable: true, get: function () { return poku_js_2.VERSION; } });
42
44
  /** 🐷 Auxiliary function to define the `poku` configurations */
43
45
  const defineConfig = (options) => options;
44
46
  exports.defineConfig = defineConfig;
@@ -5,7 +5,8 @@ const poku_js_1 = require("../configs/poku.js");
5
5
  const regex = {
6
6
  newLine: /\n/,
7
7
  ansi: /u001b\[0m|\n/i,
8
- skipped: /^"\\u001b\[94m\\u001b\[1mℹ/i,
8
+ skip: /\\u001b\[94m\\u001b\[1m◯/i,
9
+ todo: /\\u001b\[96m\\u001b\[1m●/i,
9
10
  };
10
11
  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
12
  exports.isQuiet = isQuiet;
@@ -14,8 +15,11 @@ exports.isDebug = isDebug;
14
15
  const parserOutput = (options) => {
15
16
  const { output, result, configs } = options;
16
17
  const normalizedOutput = JSON.stringify(output);
17
- if (regex.skipped.test(normalizedOutput)) {
18
- ++poku_js_1.results.skipped;
18
+ if (regex.skip.test(normalizedOutput)) {
19
+ ++poku_js_1.results.skip;
20
+ }
21
+ if (regex.todo.test(normalizedOutput)) {
22
+ ++poku_js_1.results.todo;
19
23
  }
20
24
  const debug = (0, exports.isDebug)(configs);
21
25
  const pad = (configs === null || configs === void 0 ? void 0 : configs.parallel) ? ' ' : ' ';
@@ -29,6 +29,7 @@ export declare class Formatter {
29
29
  success(): this;
30
30
  fail(): this;
31
31
  gray(): this;
32
+ cyan(): this;
32
33
  bg(color: keyof typeof backgroundColor): this;
33
34
  [Symbol.toPrimitive](): string;
34
35
  }
@@ -67,6 +67,10 @@ class Formatter {
67
67
  this.parts += '\x1b[90m';
68
68
  return this;
69
69
  }
70
+ cyan() {
71
+ this.parts += '\x1b[96m';
72
+ return this;
73
+ }
70
74
  bg(color) {
71
75
  this.parts += `\x1b[${exports.backgroundColor[color]}m\x1b[1m`;
72
76
  return this;
@@ -65,7 +65,7 @@ const runTestsParallel = async (dir, configs) => {
65
65
  const testDir = (0, node_path_1.join)(cwd, dir);
66
66
  const files = await (0, list_files_js_1.listFiles)(testDir, configs);
67
67
  const filesByConcurrency = [];
68
- const concurrencyLimit = (_a = configs === null || configs === void 0 ? void 0 : configs.concurrency) !== null && _a !== void 0 ? _a : Math.max(Math.floor((0, cpus_js_1.availableParallelism)() / 2), 1);
68
+ const concurrencyLimit = (_a = configs === null || configs === void 0 ? void 0 : configs.concurrency) !== null && _a !== void 0 ? _a : Math.max((0, cpus_js_1.availableParallelism)() - 1, 1);
69
69
  const concurrencyResults = [];
70
70
  const showLogs = !(0, output_js_1.isQuiet)(configs);
71
71
  if (concurrencyLimit > 0) {
@@ -62,18 +62,15 @@ class Watcher {
62
62
  }
63
63
  }
64
64
  async start() {
65
- try {
66
- const stats = await (0, fs_js_1.stat)(this.rootDir);
67
- if (stats.isDirectory()) {
68
- this.files = await (0, list_files_js_1.listFiles)(this.rootDir);
69
- this.watchFiles(this.files);
70
- await this.watchDirectory(this.rootDir);
71
- }
72
- else {
73
- this.watchFile(this.rootDir);
74
- }
65
+ const stats = await (0, fs_js_1.stat)(this.rootDir);
66
+ if (stats.isDirectory()) {
67
+ this.files = await (0, list_files_js_1.listFiles)(this.rootDir);
68
+ this.watchFiles(this.files);
69
+ await this.watchDirectory(this.rootDir);
70
+ }
71
+ else {
72
+ this.watchFile(this.rootDir);
75
73
  }
76
- catch (_a) { }
77
74
  }
78
75
  stop() {
79
76
  this.unwatchFiles();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "2.2.4",
3
+ "version": "2.4.0",
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",
@@ -51,7 +51,7 @@
51
51
  "clear": "rm -rf lib ci coverage .temp test-src test-tests",
52
52
  "prebuild": "npm run clear",
53
53
  "build": "tsc && tsc -p tsconfig.test.json",
54
- "postbuild": "tsx tools/compatibility/node.ts && tsx tools/compatibility/comments.ts && cp fixtures/server/package.json ci/fixtures/server/package.json && rm -f ./lib/@types/*.js ./lib/bin/*.ts && npm run build:deno && chmod +x lib/bin/index.js",
54
+ "postbuild": "tsx tools/compatibility/node.ts && tsx tools/compatibility/comments.ts && tsx tools/build/version.ts && cp fixtures/server/package.json ci/fixtures/server/package.json && rm -f ./lib/@types/*.js ./lib/bin/*.ts && npm run build:deno && chmod +x lib/bin/index.js",
55
55
  "build:deno": "tsc -p tsconfig.mjs.json",
56
56
  "postbuild:deno": "tsx tools/build/check-deno-polyfill.ts",
57
57
  "lint": "npx @biomejs/biome lint && prettier --check .",
@@ -62,13 +62,13 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@biomejs/biome": "1.8.3",
65
- "@types/node": "^20.14.12",
65
+ "@types/node": "^22.0.2",
66
66
  "c8": "^10.1.2",
67
67
  "jsonc.min": "^1.0.0",
68
- "monocart-coverage-reports": "^2.9.3",
68
+ "monocart-coverage-reports": "^2.10.0",
69
69
  "packages-update": "^2.0.0",
70
70
  "prettier": "^3.3.3",
71
- "tsx": "4.16.2",
71
+ "tsx": "4.16.5",
72
72
  "typescript": "^5.5.4"
73
73
  },
74
74
  "keywords": [
@@ -1,4 +0,0 @@
1
- export declare function it(message: string, cb: () => Promise<unknown>): Promise<void>;
2
- export declare function it(message: string, cb: () => unknown): void;
3
- export declare function it(cb: () => Promise<unknown>): Promise<void>;
4
- export declare function it(cb: () => unknown): void;