poku 1.2.0 → 1.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 CHANGED
@@ -38,23 +38,41 @@ A flexible and easy-to-use **Test Runner** for [Node.js][node-version-url], [Bun
38
38
  - No need to compile **TypeScript**
39
39
  - Compatible with **Coverage** tools
40
40
  - Allows both **in-code** and **CLI** usage
41
+ - [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url] compatibility
41
42
  - Zero configurations, except you want
42
43
  - No constraints or rules, code in your own signature style
43
44
 
44
45
  ---
45
46
 
46
- - Totally **dependency-free**
47
+ - <img src="https://img.shields.io/bundlephobia/min/poku?label=Final%20Size">
48
+ - **Zero** external dependencies
47
49
  - **Poku** dive to the deepest depths to find tests in the specified directories
48
50
  - **Compatibility:** **Poku** is tested across all **Node 6+**, **Bun 0.5.3+** and **Deno 1.30+** versions
49
51
  - **Poku** uses itself to test its own tests using `process.exit` at several depths on the same process node
50
52
 
51
53
  ---
52
54
 
53
- ```bash
54
- npx poku --include='test/unit,test/integration'
55
+ | Sequential | Parallel |
56
+ | ------------------------------------------------------------ | ---------------------------------------------------------- |
57
+ | `npx poku test/unit,test/integration` | `npx poku --parallel test/unit,test/integration` |
58
+ | <img src=".github/assets/readme/sequential.png" width="360"> | <img src=".github/assets/readme/parallel.png" width="360"> |
59
+
60
+ - By default, **Poku** searches for all _`.test.`_ files, but you can customize it using the option [`filter`](https://github.com/wellwelwel/poku#filter-rexexp).
61
+ - The same idea for [**Bun**][bun-version-url] and [**Deno**][deno-version-url] (see bellow).
62
+
63
+ ---
64
+
65
+ **Poku** also includes the `assert` method, keeping everything as it is, but providing human readability:
66
+
67
+ ```ts
68
+ import { assert } from 'poku'; // Node and Bun
69
+ import { assert } from 'npm:poku'; // Deno
70
+
71
+ assert(true);
72
+ assert.deepStrictEqual(1, '1', 'My optional custom message');
55
73
  ```
56
74
 
57
- <img src="./.github/assets/readme/screen-recording-2024-02-17-at-23.38.06.gif" width="360">
75
+ > <img src=".github/assets/readme/assert.png" width="468" />
58
76
 
59
77
  ---
60
78
 
@@ -113,7 +131,7 @@ import { poku } from 'npm:poku';
113
131
  ```ts
114
132
  import { poku } from 'poku';
115
133
 
116
- await poku(['./a', './b']);
134
+ await poku(['targetDirA', 'targetDirB']);
117
135
  ```
118
136
 
119
137
  > <img src=".github/assets/readme/deno.svg" width="24" />
@@ -121,7 +139,7 @@ await poku(['./a', './b']);
121
139
  ```ts
122
140
  import { poku } from 'npm:poku';
123
141
 
124
- await poku(['./a', './b']);
142
+ await poku(['targetDirA', 'targetDirB']);
125
143
  ```
126
144
 
127
145
  ### CLI
@@ -129,19 +147,19 @@ await poku(['./a', './b']);
129
147
  > <img src=".github/assets/readme/node-js.svg" width="24" />
130
148
 
131
149
  ```bash
132
- npx poku --include='./a,./b'
150
+ npx poku targetDirA,targetDirB
133
151
  ```
134
152
 
135
153
  > <img src=".github/assets/readme/bun.svg" width="24" />
136
154
 
137
155
  ```bash
138
- bun poku --include='./a,./b'
156
+ bun poku targetDirA,targetDirB
139
157
  ```
140
158
 
141
159
  > <img src=".github/assets/readme/deno.svg" width="24" />
142
160
 
143
161
  ```bash
144
- deno run npm:poku --include='./a,./b'
162
+ deno run npm:poku targetDirA,targetDirB
145
163
  ```
146
164
 
147
165
  ---
@@ -156,20 +174,40 @@ deno run npm:poku --include='./a,./b'
156
174
 
157
175
  #### Include directories
158
176
 
177
+ - **in-code**
178
+
159
179
  ```ts
160
- poku('./targetDir');
180
+ poku('targetDir');
161
181
  ```
162
182
 
163
183
  ```ts
164
- poku(['./targetDirA', './targetDirB']);
184
+ poku(['targetDirA', 'targetDirB']);
185
+ ```
186
+
187
+ - **CLI**
188
+
189
+ By setting the directories as the last argument:
190
+
191
+ > _Since **1.3.0**_
192
+
193
+ ```bash
194
+ npx poku targetDir
165
195
  ```
166
196
 
167
197
  ```bash
168
- npx poku --include='./targetDir'
198
+ npx poku targetDirA,targetDirB
199
+ ```
200
+
201
+ By using `--include` option:
202
+
203
+ > _Since **1.0.0**_
204
+
205
+ ```bash
206
+ npx poku --include='targetDir'
169
207
  ```
170
208
 
171
209
  ```bash
172
- npx poku --include='./targetDirA,./targetDirB'
210
+ npx poku --include='targetDirA,targetDirB'
173
211
  ```
174
212
 
175
213
  ---
@@ -211,7 +249,7 @@ poku(['...'], {
211
249
  ```bash
212
250
  # Parallel mode
213
251
 
214
- npx poku --include='...' --parallel
252
+ npx poku --parallel ./test
215
253
  ```
216
254
 
217
255
  ---
@@ -261,23 +299,25 @@ poku('...', {
261
299
  ```bash
262
300
  # Normal
263
301
 
264
- npx poku --include='...' --platform=node
265
- bun poku --include='...' --platform=bun
266
- deno poku --include='...' --platform=deno
302
+ npx poku --platform=node ./test
303
+ bun poku --platform=bun ./test
304
+ deno run npm:poku --platform=deno ./test
267
305
  ```
268
306
 
269
307
  ```bash
270
308
  # Custom
309
+ # When you're developing using a platform, but maintain compatibility with others
310
+
311
+ npx poku --platform=bun ./test
312
+ bun poku --platform=deno ./test
313
+ deno run npm:poku --platform=node ./test
271
314
 
272
- npx poku --include='...' --platform=bun
273
- bun poku --include='...' --platform=deno
274
- deno run poku --include='...' --platform=node
275
315
  # ...
276
316
  ```
277
317
 
278
318
  ---
279
319
 
280
- #### `filter: RexExp`
320
+ #### `filter: RegExp`
281
321
 
282
322
  By default, **Poku** searches for _`.test.`_ files, but you can customize it using the `filter` option.
283
323
 
@@ -303,7 +343,7 @@ poku(['...'], {
303
343
  */
304
344
 
305
345
  poku(['...'], {
306
- filter: /\.(m)?(j|t)?s$/,
346
+ filter: /\.(m)?(j|t)s$/,
307
347
  // filter: /\.(js|ts|mjs|mts)$/,
308
348
  });
309
349
  ```
@@ -313,19 +353,19 @@ poku(['...'], {
313
353
  ```bash
314
354
  # Testing only a specific file
315
355
 
316
- npx poku --include='...' --filter='some-file'
356
+ npx poku --filter='some-file' ./test
317
357
  ```
318
358
 
319
359
  ```bash
320
360
  # Testing only a specific file
321
361
 
322
- npx poku --include='...' --filter='some-file|other-file'
362
+ npx poku --filter='some-file|other-file' ./test
323
363
  ```
324
364
 
325
365
  ```bash
326
366
  # Testing only paths that contains "unit"
327
367
 
328
- npx poku --include='...' --filter='unit'
368
+ npx poku --filter='unit' ./test
329
369
  ```
330
370
 
331
371
  - **Environment Variable**
@@ -335,24 +375,24 @@ npx poku --include='...' --filter='unit'
335
375
  ```bash
336
376
  # Testing only a specific file
337
377
 
338
- FILTER='some-file' npx poku --include='...'
378
+ FILTER='some-file' npx poku ./test
339
379
  ```
340
380
 
341
381
  ```bash
342
382
  # Testing only a specific file
343
383
 
344
- FILTER='some-file|other-file' npx poku --include='...'
384
+ FILTER='some-file|other-file' npx poku ./test
345
385
  ```
346
386
 
347
387
  ```bash
348
388
  # Testing only paths that contains "unit"
349
389
 
350
- FILTER='unit' npx poku --include='...'
390
+ FILTER='unit' npx poku ./test
351
391
  ```
352
392
 
353
393
  ---
354
394
 
355
- #### `exclude: RexExp | RexExp[]`
395
+ #### `exclude: RegExp | RegExp[]`
356
396
 
357
397
  > Exclude by path using Regex to match only the files that should be performed.
358
398
  >
@@ -425,17 +465,50 @@ poku(['...'], {
425
465
  ```bash
426
466
  # Excluding directories and files from tests
427
467
 
428
- npx poku --include='...' --exclude='some-file-or-dir'
468
+ npx poku --exclude='some-file-or-dir' ./test
429
469
  ```
430
470
 
431
471
  ```bash
432
472
  # Excluding directories and files from tests
433
473
 
434
- npx poku --include='...' --exclude='some-file-or-dir|other-file-or-dir'
474
+ npx poku --exclude='some-file-or-dir|other-file-or-dir' ./test
435
475
  ```
436
476
 
437
477
  ---
438
478
 
479
+ ### Assert
480
+
481
+ > _Since **1.3.0**_
482
+ >
483
+ > [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url] compatible.
484
+
485
+ **Poku** includes the `assert` method, keeping everything as it is, but providing human readability.
486
+
487
+ **Available methods:**
488
+
489
+ - `assert(value[, message])`
490
+ - `assert.deepEqual(actual, expected[, message])`
491
+ - `assert.deepStrictEqual(actual, expected[, message])`
492
+ - `assert.doesNotMatch(string, regexp[, message])`
493
+ - `assert.doesNotReject(asyncFn[, error][, message])`
494
+ - `assert.doesNotThrow(fn[, error][, message])`
495
+ - `assert.equal(actual, expected[, message])`
496
+ - `assert.fail([message])`
497
+ - `assert.ifError(value)`
498
+ - `assert.match(string, regexp[, message])`
499
+ - `assert.notDeepEqual(actual, expected[, message])`
500
+ - `assert.notDeepStrictEqual(actual, expected[, message])`
501
+ - `assert.notEqual(actual, expected[, message])`
502
+ - `assert.notStrictEqual(actual, expected[, message])`
503
+ - `assert.ok(value[, message])`
504
+ - `assert.rejects(asyncFn[, error][, message])`
505
+ - `assert.strictEqual(actual, expected[, message])`
506
+ - `assert.throws(fn[, error][, message])`
507
+
508
+ You can follow the [**assert documentation**](https://nodejs.org/api/assert.html) from **Node.js**'s documentation.
509
+
510
+ ---
511
+
439
512
  ### `listFiles(targetDir: string, configs?: ListFilesConfigs)`
440
513
 
441
514
  > _Since **1.2.0**_
package/lib/bin/index.js CHANGED
@@ -1,12 +1,14 @@
1
1
  #! /usr/bin/env node
2
2
  "use strict";
3
- var _a;
3
+ var _a, _b;
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  const list_files_js_1 = require("../modules/list-files.js");
6
6
  const get_arg_js_1 = require("../helpers/get-arg.js");
7
7
  const index_js_1 = require("../index.js");
8
8
  const get_runtime_js_1 = require("../helpers/get-runtime.js");
9
- const dirs = ((_a = (0, get_arg_js_1.getArg)('include')) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
9
+ const dirs = ((0, get_arg_js_1.hasArg)('include')
10
+ ? (_a = (0, get_arg_js_1.getArg)('include')) === null || _a === void 0 ? void 0 : _a.split(',')
11
+ : (_b = (0, get_arg_js_1.getLastParam)()) === null || _b === void 0 ? void 0 : _b.split(',')) || [];
10
12
  const platform = (0, get_arg_js_1.getArg)('platform');
11
13
  const filter = (0, get_arg_js_1.getArg)('filter');
12
14
  const parallel = (0, get_arg_js_1.hasArg)('parallel');
@@ -1,5 +1,6 @@
1
1
  export declare const format: {
2
2
  counter: (current: number, total: number, pad?: string) => string;
3
+ dim: (value: string) => string;
3
4
  bold: (value: string) => string;
4
5
  underline: (value: string) => string;
5
6
  info: (value: string) => string;
@@ -7,6 +7,7 @@ exports.format = {
7
7
  const totalDigits = String(total).length;
8
8
  return (0, pad_js_1.padStart)(String(current), totalDigits, pad);
9
9
  },
10
+ dim: (value) => `\x1b[2m${value}\x1b[0m`,
10
11
  bold: (value) => `\x1b[1m${value}\x1b[0m`,
11
12
  underline: (value) => `\x1b[4m${value}\x1b[0m`,
12
13
  info: (value) => `\x1b[36m${value}\x1b[0m`,
@@ -1,2 +1,3 @@
1
1
  export declare const getArg: (arg: string) => string | undefined;
2
2
  export declare const hasArg: (arg: string) => boolean;
3
+ export declare const getLastParam: () => string;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.hasArg = exports.getArg = void 0;
6
+ exports.getLastParam = exports.hasArg = exports.getArg = void 0;
7
7
  const node_process_1 = __importDefault(require("process"));
8
8
  const [, , ...args] = node_process_1.default.argv;
9
9
  const getArg = (arg) => {
@@ -16,3 +16,7 @@ const getArg = (arg) => {
16
16
  exports.getArg = getArg;
17
17
  const hasArg = (arg) => args.some((a) => a.startsWith(`--${arg}`));
18
18
  exports.hasArg = hasArg;
19
+ const getLastParam = () => {
20
+ return args[args.length - 1];
21
+ };
22
+ exports.getLastParam = getLastParam;
package/lib/helpers/hr.js CHANGED
@@ -8,7 +8,7 @@ const node_os_1 = require("os");
8
8
  const node_process_1 = __importDefault(require("process"));
9
9
  const hr = () => {
10
10
  const columns = node_process_1.default.stdout.columns;
11
- const line = '_'.repeat(columns - 10 || 0);
11
+ const line = '_'.repeat(columns - 10 || 30);
12
12
  console.log(`\x1b[2m${line}\x1b[0m${node_os_1.EOL}`);
13
13
  };
14
14
  exports.hr = hr;
@@ -0,0 +1,9 @@
1
+ export type ParseAssertionOptions = {
2
+ message?: string | Error;
3
+ defaultMessage?: string;
4
+ actual?: string;
5
+ expected?: string;
6
+ throw?: boolean;
7
+ hideDiff?: boolean;
8
+ };
9
+ export declare const parseAssertion: (cb: () => void, options: ParseAssertionOptions) => void;
@@ -0,0 +1,68 @@
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.parseAssertion = void 0;
7
+ const node_process_1 = __importDefault(require("process"));
8
+ const node_assert_1 = __importDefault(require("assert"));
9
+ const node_os_1 = require("os");
10
+ const format_js_1 = require("./format.js");
11
+ const hr_js_1 = require("./hr.js");
12
+ const findFile = (error) => {
13
+ var _a;
14
+ const stackLines = ((_a = error.stack) === null || _a === void 0 ? void 0 : _a.split(node_os_1.EOL)) || [];
15
+ let file = '';
16
+ const basePath = 'poku/lib/';
17
+ for (const line of stackLines) {
18
+ if (!line.includes(basePath)) {
19
+ const match = line.match(/at\s(\/.+|file:\/\/\/.+)/i);
20
+ if (match && match[1]) {
21
+ file = match[1];
22
+ break;
23
+ }
24
+ }
25
+ }
26
+ return file;
27
+ };
28
+ const parseAssertion = (cb, options) => {
29
+ try {
30
+ cb();
31
+ }
32
+ catch (error) {
33
+ if (error instanceof node_assert_1.default.AssertionError) {
34
+ const { code, actual, expected, operator } = error;
35
+ const file = findFile(error);
36
+ (0, hr_js_1.hr)();
37
+ if (typeof options.message === 'string')
38
+ console.log(format_js_1.format.bold(options.message), node_os_1.EOL);
39
+ else if (options.message instanceof Error)
40
+ console.log(format_js_1.format.bold(options.message.message), node_os_1.EOL);
41
+ else if (typeof options.defaultMessage === 'string')
42
+ console.log(options.defaultMessage, node_os_1.EOL);
43
+ console.log(format_js_1.format.dim('Code: '), format_js_1.format.bold(format_js_1.format.fail(code)));
44
+ file && console.log(format_js_1.format.dim('File: '), file);
45
+ console.log(format_js_1.format.dim('Operator:'), operator);
46
+ (0, hr_js_1.hr)();
47
+ if (!(options === null || options === void 0 ? void 0 : options.hideDiff)) {
48
+ console.log(format_js_1.format.dim(`${(options === null || options === void 0 ? void 0 : options.actual) || 'Actual'}:`));
49
+ console.log(format_js_1.format.bold(typeof actual === 'function' || actual instanceof RegExp
50
+ ? String(actual)
51
+ : format_js_1.format.fail(JSON.stringify(actual))));
52
+ console.log(`${node_os_1.EOL}${format_js_1.format.dim(`${(options === null || options === void 0 ? void 0 : options.expected) || 'Expected'}:`)}`);
53
+ console.log(format_js_1.format.bold(typeof expected === 'function' || expected instanceof RegExp
54
+ ? String(expected)
55
+ : format_js_1.format.success(JSON.stringify(expected))));
56
+ (0, hr_js_1.hr)();
57
+ }
58
+ if (options.throw) {
59
+ console.log(error);
60
+ (0, hr_js_1.hr)();
61
+ }
62
+ node_process_1.default.exit(1);
63
+ }
64
+ // Non-assertion errors
65
+ throw error;
66
+ }
67
+ };
68
+ exports.parseAssertion = parseAssertion;
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { poku } from './modules/poku.js';
2
2
  export { exit } from './modules/exit.js';
3
+ export { assert } from './modules/assert.js';
3
4
  export { publicListFiles as listFiles } from './modules/list-files.js';
4
5
  export type { Code } from './@types/code.ts';
5
6
  export type { Configs } from './@types/poku.ts';
package/lib/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listFiles = exports.exit = exports.poku = void 0;
3
+ exports.listFiles = exports.assert = exports.exit = exports.poku = void 0;
4
4
  var poku_js_1 = require("./modules/poku.js");
5
5
  Object.defineProperty(exports, "poku", { enumerable: true, get: function () { return poku_js_1.poku; } });
6
6
  var exit_js_1 = require("./modules/exit.js");
7
7
  Object.defineProperty(exports, "exit", { enumerable: true, get: function () { return exit_js_1.exit; } });
8
+ var assert_js_1 = require("./modules/assert.js");
9
+ Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_js_1.assert; } });
8
10
  var list_files_js_1 = require("./modules/list-files.js");
9
11
  Object.defineProperty(exports, "listFiles", { enumerable: true, get: function () { return list_files_js_1.publicListFiles; } });
@@ -0,0 +1,31 @@
1
+ /// <reference types="node" />
2
+ import * as nodeAssert from 'node:assert';
3
+ import { ParseAssertionOptions } from '../helpers/parseAsssetion.js';
4
+ declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
5
+ declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>;
6
+ declare function doesNotThrow(block: () => unknown, message?: string | ParseAssertionOptions['message']): void;
7
+ declare function doesNotThrow(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): void;
8
+ declare function throws(block: () => unknown, message?: ParseAssertionOptions['message']): void;
9
+ declare function throws(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): void;
10
+ declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
11
+ declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>;
12
+ export declare const assert: ((value: unknown, message?: ParseAssertionOptions['message']) => void) & {
13
+ ok: (value: unknown, message?: ParseAssertionOptions['message']) => void;
14
+ equal: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => void;
15
+ deepEqual: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => void;
16
+ strictEqual: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => void;
17
+ deepStrictEqual: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => void;
18
+ doesNotMatch: (value: string, regExp: RegExp, message?: ParseAssertionOptions['message']) => void;
19
+ doesNotReject: typeof doesNotReject;
20
+ throws: typeof throws;
21
+ doesNotThrow: typeof doesNotThrow;
22
+ notEqual: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => void;
23
+ notDeepEqual: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => void;
24
+ notStrictEqual: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => void;
25
+ notDeepStrictEqual: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => void;
26
+ match: (value: string, regExp: RegExp, message?: ParseAssertionOptions['message']) => void;
27
+ ifError: (value: unknown) => void;
28
+ fail: (message?: ParseAssertionOptions['message']) => void;
29
+ rejects: typeof rejects;
30
+ };
31
+ export {};
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.assert = void 0;
36
+ const nodeAssert = __importStar(require("assert"));
37
+ const parseAsssetion_js_1 = require("../helpers/parseAsssetion.js");
38
+ const format_js_1 = require("../helpers/format.js");
39
+ const ok = (value, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.ok(value), { message });
40
+ const equal = (actual, expected, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.equal(actual, expected), { message });
41
+ const deepEqual = (actual, expected, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.deepEqual(actual, expected), { message });
42
+ const strictEqual = (actual, expected, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.strictEqual(actual, expected), { message });
43
+ const deepStrictEqual = (actual, expected, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.deepStrictEqual(actual, expected), {
44
+ message,
45
+ });
46
+ const doesNotMatch = (value, regExp, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.doesNotMatch(value, regExp), {
47
+ message,
48
+ actual: 'Value',
49
+ expected: 'RegExp',
50
+ defaultMessage: format_js_1.format.bold('Value should not match regExp'),
51
+ });
52
+ function doesNotReject(block, errorOrMessage, message) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ if (typeof errorOrMessage === 'function' ||
55
+ errorOrMessage instanceof RegExp ||
56
+ typeof errorOrMessage === 'object') {
57
+ try {
58
+ return yield nodeAssert.doesNotReject(block, errorOrMessage);
59
+ }
60
+ catch (error) {
61
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
62
+ throw error;
63
+ }, {
64
+ message,
65
+ defaultMessage: format_js_1.format.bold('Got unwanted rejection'),
66
+ hideDiff: true,
67
+ throw: true,
68
+ });
69
+ }
70
+ }
71
+ else {
72
+ try {
73
+ return yield nodeAssert.doesNotReject(block);
74
+ }
75
+ catch (error_1) {
76
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
77
+ throw error_1;
78
+ }, {
79
+ message: typeof errorOrMessage === 'string' ? errorOrMessage : undefined,
80
+ defaultMessage: format_js_1.format.bold('Got unwanted rejection'),
81
+ hideDiff: true,
82
+ throw: true,
83
+ });
84
+ }
85
+ }
86
+ });
87
+ }
88
+ function doesNotThrow(block, errorOrMessage, message) {
89
+ if (typeof errorOrMessage === 'function' ||
90
+ errorOrMessage instanceof RegExp ||
91
+ typeof errorOrMessage === 'object') {
92
+ try {
93
+ nodeAssert.doesNotThrow(block, errorOrMessage, message);
94
+ }
95
+ catch (error) {
96
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
97
+ throw error;
98
+ }, {
99
+ message: message,
100
+ defaultMessage: format_js_1.format.bold('Expected function not to throw'),
101
+ hideDiff: true,
102
+ throw: true,
103
+ });
104
+ }
105
+ }
106
+ else {
107
+ const msg = typeof errorOrMessage === 'string' ? errorOrMessage : undefined;
108
+ try {
109
+ nodeAssert.doesNotThrow(block, msg);
110
+ }
111
+ catch (error) {
112
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
113
+ throw error;
114
+ }, {
115
+ message: msg,
116
+ defaultMessage: format_js_1.format.bold('Expected function not to throw'),
117
+ hideDiff: true,
118
+ throw: true,
119
+ });
120
+ }
121
+ }
122
+ }
123
+ function throws(block, errorOrMessage, message) {
124
+ if (typeof errorOrMessage === 'function' ||
125
+ errorOrMessage instanceof RegExp ||
126
+ typeof errorOrMessage === 'object') {
127
+ try {
128
+ nodeAssert.throws(block, errorOrMessage, message);
129
+ }
130
+ catch (error) {
131
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
132
+ throw error;
133
+ }, {
134
+ message: message,
135
+ defaultMessage: format_js_1.format.bold('Expected function to throw'),
136
+ hideDiff: true,
137
+ });
138
+ }
139
+ }
140
+ else {
141
+ const msg = typeof errorOrMessage === 'string' ? errorOrMessage : undefined;
142
+ try {
143
+ nodeAssert.throws(block, message);
144
+ }
145
+ catch (error) {
146
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
147
+ throw error;
148
+ }, {
149
+ message: msg,
150
+ defaultMessage: format_js_1.format.bold('Expected function to throw'),
151
+ hideDiff: true,
152
+ });
153
+ }
154
+ }
155
+ }
156
+ const notEqual = (actual, expected, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notEqual(actual, expected), {
157
+ message,
158
+ });
159
+ const notDeepEqual = (actual, expected, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notDeepEqual(actual, expected), { message });
160
+ const notStrictEqual = (actual, expected, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notStrictEqual(actual, expected), {
161
+ message,
162
+ });
163
+ const notDeepStrictEqual = (actual, expected, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.notDeepStrictEqual(actual, expected), {
164
+ message,
165
+ });
166
+ const match = (value, regExp, message) => (0, parseAsssetion_js_1.parseAssertion)(() => nodeAssert.match(value, regExp), {
167
+ message,
168
+ actual: 'Value',
169
+ expected: 'RegExp',
170
+ defaultMessage: format_js_1.format.bold('Value should match regExp'),
171
+ });
172
+ const ifError = (value) => {
173
+ try {
174
+ nodeAssert.ifError(value);
175
+ }
176
+ catch (error) {
177
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
178
+ throw error;
179
+ }, {
180
+ defaultMessage: format_js_1.format.bold('Expected no error, but received an error'),
181
+ hideDiff: true,
182
+ throw: true,
183
+ });
184
+ }
185
+ };
186
+ const fail = (message) => {
187
+ try {
188
+ nodeAssert.fail(message);
189
+ }
190
+ catch (error) {
191
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
192
+ throw error;
193
+ }, {
194
+ message,
195
+ defaultMessage: format_js_1.format.bold('Test failed intentionally'),
196
+ hideDiff: true,
197
+ });
198
+ }
199
+ };
200
+ function rejects(block, errorOrMessage, message) {
201
+ return __awaiter(this, void 0, void 0, function* () {
202
+ if (typeof errorOrMessage === 'function' ||
203
+ errorOrMessage instanceof RegExp ||
204
+ typeof errorOrMessage === 'object') {
205
+ try {
206
+ return yield nodeAssert.rejects(block, errorOrMessage);
207
+ }
208
+ catch (error) {
209
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
210
+ throw error;
211
+ }, {
212
+ message,
213
+ defaultMessage: format_js_1.format.bold('Expected promise to be rejected with specified error'),
214
+ hideDiff: true,
215
+ });
216
+ }
217
+ }
218
+ else {
219
+ const msg = typeof errorOrMessage === 'string' ? errorOrMessage : undefined;
220
+ try {
221
+ return yield nodeAssert.rejects(block);
222
+ }
223
+ catch (error_1) {
224
+ (0, parseAsssetion_js_1.parseAssertion)(() => {
225
+ throw error_1;
226
+ }, {
227
+ message: msg,
228
+ defaultMessage: format_js_1.format.bold('Expected promise to be rejected'),
229
+ hideDiff: true,
230
+ });
231
+ }
232
+ }
233
+ });
234
+ }
235
+ exports.assert = Object.assign((value, message) => ok(value, message), {
236
+ ok,
237
+ equal,
238
+ deepEqual,
239
+ strictEqual,
240
+ deepStrictEqual,
241
+ doesNotMatch,
242
+ doesNotReject,
243
+ throws,
244
+ doesNotThrow,
245
+ notEqual,
246
+ notDeepEqual,
247
+ notStrictEqual,
248
+ notDeepStrictEqual,
249
+ match,
250
+ ifError,
251
+ fail,
252
+ rejects,
253
+ });
@@ -8,7 +8,7 @@ exports.publicListFiles = exports.listFiles = exports.escapeRegExp = void 0;
8
8
  const node_process_1 = __importDefault(require("process"));
9
9
  const node_fs_1 = __importDefault(require("fs"));
10
10
  const node_path_1 = __importDefault(require("path"));
11
- const escapeRegExp = (string) => string.replace(/[.*+?^${}()[\]\\]/g, '\\$&');
11
+ const escapeRegExp = (string) => string.replace(/[.*{}[\]\\]/g, '\\$&');
12
12
  exports.escapeRegExp = escapeRegExp;
13
13
  const envFilter = ((_a = node_process_1.default.env.FILTER) === null || _a === void 0 ? void 0 : _a.trim())
14
14
  ? new RegExp((0, exports.escapeRegExp)(node_process_1.default.env.FILTER), 'i')
@@ -16,7 +16,7 @@ const runTestFile = (filePath, configs) => new Promise((resolve) => {
16
16
  const showLogs = !(0, logs_js_1.isQuiet)(configs);
17
17
  const showSuccess = (0, logs_js_1.showSuccesses)(configs);
18
18
  const showFailure = (0, logs_js_1.showFailures)(configs);
19
- const log = () => console.log(`${indentation_js_1.indentation.stdio}${output === null || output === void 0 ? void 0 : output.trim()}`);
19
+ const log = () => console.log(output === null || output === void 0 ? void 0 : output.trim());
20
20
  const fileRelative = node_path_1.default.relative(node_process_1.default.cwd(), filePath);
21
21
  showLogs &&
22
22
  console.log(`${indentation_js_1.indentation.test}${format_js_1.format.info('→')} ${fileRelative}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "🐷 Poku is a flexible and easy-to-use Test Runner for Node.js, Bun and Deno that allows you to run parallel and sequential tests, plus high isolation level per test file",
5
5
  "main": "./lib/index.js",
6
6
  "scripts": {
@@ -12,7 +12,7 @@
12
12
  "update": "npx npu;",
13
13
  "prebuild": "rm -rf ./lib ./ci",
14
14
  "build": "npx tsc; npx tsc -p tsconfig.test.json",
15
- "postbuild": "npx tsx ./tools/compatibility/node.ts; npm audit",
15
+ "postbuild": "npx tsx ./tools/compatibility/node.ts; chmod +x lib/bin/index.js; npm audit",
16
16
  "eslint:checker": "npx eslint . --ext .js,.ts",
17
17
  "eslint:fix": "npx eslint . --fix --config ./.eslintrc.json",
18
18
  "prettier:checker": "npx prettier --check .",
@@ -27,9 +27,12 @@
27
27
  "poku": "./lib/bin/index.js"
28
28
  },
29
29
  "keywords": [
30
+ "🐷",
30
31
  "test",
31
- "testing",
32
32
  "runner",
33
+ "assert",
34
+ "assertion",
35
+ "testing",
33
36
  "run",
34
37
  "isolate",
35
38
  "isolation",
@@ -41,13 +44,29 @@
41
44
  "unit",
42
45
  "integration",
43
46
  "typescript",
44
- "filter",
45
47
  "queue",
46
48
  "queuing",
47
49
  "nodejs",
48
50
  "node",
49
51
  "bun",
50
- "deno"
52
+ "deno",
53
+ "cli",
54
+ "cli-app",
55
+ "expect",
56
+ "mocha",
57
+ "jest",
58
+ "ava",
59
+ "tap",
60
+ "tape",
61
+ "karma",
62
+ "filter",
63
+ "exclude",
64
+ "list",
65
+ "files",
66
+ "list-files",
67
+ "tsx",
68
+ "fast",
69
+ "easy"
51
70
  ],
52
71
  "author": "https://github.com/wellwelwel",
53
72
  "bugs": {