poku 1.3.1 → 1.5.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
@@ -4,75 +4,102 @@
4
4
  [bun-version-image]: https://img.shields.io/badge/Bun->=0.5.3-f471b5
5
5
  [deno-version-url]: https://github.com/denoland/deno
6
6
  [deno-version-image]: https://img.shields.io/badge/Deno->=1.30.0-70ffaf
7
- [npm-image]: https://img.shields.io/npm/v/poku.svg?color=3dc1d3
8
- [npm-url]: https://npmjs.org/package/poku
7
+ [typescript-url]: https://github.com/microsoft/TypeScript
8
+ [typescript-version-image]: https://img.shields.io/badge/TypeScript->=5.0.2-3077c6
9
9
  [ci-url]: https://github.com/wellwelwel/poku/actions/workflows/ci.yml?query=branch%3Amain
10
10
  [ci-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci.yml?event=push&style=flat&label=CI&branch=main
11
11
  [ql-url]: https://github.com/wellwelwel/poku/actions/workflows/codeql.yml?query=branch%3Amain
12
12
  [ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/codeql.yml?event=push&style=flat&label=Code%20QL&branch=main
13
- [license-url]: https://github.com/wellwelwel/poku/blob/main/LICENSE
14
- [license-image]: https://img.shields.io/npm/l/poku.svg?maxAge=2592000&color=9c88ff
15
13
 
16
14
  # Poku
17
15
 
18
16
  <img align="right" width="128" height="128" alt="Logo" src=".github/assets/readme/poku.svg">
19
17
 
20
- A flexible and easy-to-use **Test Runner** for [Node.js][node-version-url], [Bun][bun-version-url] and [Deno][deno-version-url] that allows you to run **parallel** and **sequential** tests, plus **high isolation level per test file**.
18
+ **Poku** is your test runner pet for [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url] combining **flexibility**, **parallel** and **sequential** runs, **human-friendly assertion errors** and **high isolation level**.
21
19
 
22
20
  [![Node.js Version][node-version-image]][node-version-url]
23
21
  [![Bun Version][bun-version-image]][bun-version-url]
24
22
  [![Deno Version][deno-version-image]][deno-version-url]
25
- [![NPM Version][npm-image]][npm-url]
26
- [![License][license-image]][license-url]
23
+ [![TypeScript Version][typescript-version-image]][typescript-url]
27
24
  [![GitHub Workflow Status (with event)][ci-image]][ci-url]
28
25
  [![GitHub Workflow Status (with event)][ql-image]][ql-url]
29
26
 
27
+ Enjoying **Poku**? Consider giving him a star ⭐️
28
+
29
+ ---
30
+
31
+ 🐷 [**Documentation Website**](https://poku.dev) • 🔬 [**Compare Poku with the Most Popular Test Runners**](https://poku.dev/docs/comparing)
32
+
30
33
  ---
31
34
 
32
35
  ## Why Poku?
33
36
 
34
- > **Poku** starts from the premise where tests come to help, not overcomplicate: runs test files in an individual process per file, shows progress and exits 🧙🏻
37
+ Don't worry about `describe`, `it`, `beforeEach` and everything else 🚀
38
+
39
+ > You don't need to learn what you already know ✨
35
40
 
36
41
  - Supports **ESM** and **CJS**
37
42
  - Designed to be highly intuitive
38
- - No need to compile **TypeScript**
43
+ - No need to compile [**TypeScript**][typescript-url] \*
39
44
  - Compatible with **Coverage** tools
40
45
  - Allows both **in-code** and **CLI** usage
41
46
  - [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url] compatibility
42
47
  - Zero configurations, except you want
43
- - No constraints or rules, code in your own signature style
48
+ - Poku adapts to your test, not the other way around
49
+ - [**And much more!**](https://poku.dev)
44
50
 
45
51
  ---
46
52
 
47
- - <img src="https://img.shields.io/bundlephobia/min/poku?label=Final%20Size">
48
- - **Zero** external dependencies
49
- - **Poku** dive to the deepest depths to find tests in the specified directories
50
- - **Compatibility:** **Poku** is tested across all **Node 6+**, **Bun 0.5.3+** and **Deno 1.30+** versions
51
- - **Poku** uses itself to test its own tests using `process.exit` at several depths on the same process node
53
+ - <img src="https://img.shields.io/bundlephobia/min/poku">
54
+ - **Zero** external dependencies 🌱
52
55
 
53
56
  ---
54
57
 
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"> |
58
+ ## Documentation
59
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).
60
+ - See detailed usage in [**Documentation**](https://poku.dev/docs/category/documentation) section for **Poku**'s **CLI**, **API (_in-code_)** and **assert**, advanced concepts and much more.
62
61
 
63
62
  ---
64
63
 
65
- **Poku** also includes the `assert` method, keeping everything as it is, but providing human readability:
64
+ ## Overview
65
+
66
+ | Sequential | Concurrent |
67
+ | -------------------------------------------------- | ------------------------------------------------ |
68
+ | <img src=".github/assets/readme/sequential.png" /> | <img src=".github/assets/readme/parallel.png" /> |
69
+
70
+ - By default, **Poku**:
71
+ - Searches for all _`.test.`_ and `.spec.` files, but you can customize it using the option [**`filter`**](https://poku.dev/docs/documentation/poku/configs/filter).
72
+ - Uses `sequential` mode.
73
+ - You can use concurrecy by use the flag `--parallel` for **CLI** or the option `parallel` to `true` in **API** (_in-code_) usage.
74
+
75
+ > Follow the same idea for [**Bun**][bun-version-url] and [**Deno**][deno-version-url].
76
+
77
+ ---
78
+
79
+ **Poku** also includes the `assert` method, keeping everything as it is, but providing human readability and automatic `describe` and `it`:
80
+
81
+ > Compatible with **Node.js**, **Bun** and **Deno**.
66
82
 
67
83
  ```ts
68
84
  import { assert } from 'poku'; // Node and Bun
69
85
  import { assert } from 'npm:poku'; // Deno
70
86
 
71
- assert(true);
72
- assert.deepStrictEqual(1, '1', 'My optional custom message');
87
+ const actual = '1';
88
+
89
+ assert(actual, 'My first assert');
90
+ assert.deepStrictEqual(actual, 1, 'My first assert error');
73
91
  ```
74
92
 
75
- > <img src=".github/assets/readme/assert.png" width="468" />
93
+ | Using `poku` | Using `node` |
94
+ | --------------------------------------------------- | --------------------------------------------------- |
95
+ | <img src=".github/assets/readme/assert-poku.png" /> | <img src=".github/assets/readme/assert-node.png" /> |
96
+
97
+ - ❌ Both cases finish with `code 1`, as expected
98
+ - 🧑🏻‍🎓 The `message` param is optional, as it's in **Node.js**
99
+ - 💚 Yes, you can use **Poku**'s `assert` running `node ./my-file.js`
100
+ - 🐷 Unlike most, **Poku** adapts to your test, not the other way around
101
+
102
+ > [**See the complete assert's documentation**](https://poku.dev/docs/documentation/assert).
76
103
 
77
104
  ---
78
105
 
@@ -80,66 +107,48 @@ assert.deepStrictEqual(1, '1', 'My optional custom message');
80
107
 
81
108
  ### **Node.js**
82
109
 
83
- > <img src=".github/assets/readme/node-js.svg" width="24" />
84
-
85
110
  ```bash
86
- npm install --save-dev poku
111
+ npm i -D poku
87
112
  ```
88
113
 
89
114
  ### TypeScript (Node.js)
90
115
 
91
- > <img src=".github/assets/readme/node-js.svg" width="24" />
92
- > <img src=".github/assets/readme/plus.svg" width="24" />
93
- > <img src=".github/assets/readme/typescript.svg" width="24" />
94
-
95
116
  ```bash
96
- npm install --save-dev poku tsx
117
+ npm i -D poku tsx
97
118
  ```
98
119
 
99
120
  ### Bun
100
121
 
101
- > <img src=".github/assets/readme/bun.svg" width="24" />
102
- > <img src=".github/assets/readme/plus.svg" width="24" />
103
- > <img src=".github/assets/readme/typescript.svg" width="24" />
104
-
105
122
  ```bash
106
- bun add --dev poku
123
+ bun add -d poku
107
124
  ```
108
125
 
109
126
  ### **Deno**
110
127
 
111
- > <img src=".github/assets/readme/deno.svg" width="24" />
112
- > <img src=".github/assets/readme/plus.svg" width="24" />
113
- > <img src=".github/assets/readme/typescript.svg" width="24" />
114
-
115
128
  ```ts
116
129
  import { poku } from 'npm:poku';
117
130
  ```
118
131
 
119
- - **Poku** requires these permissions by default: `--allow-read`, `--allow-env` and `--allow-run`.
120
-
121
132
  ---
122
133
 
123
- ## Basic Usage
134
+ ## Quick Start
124
135
 
125
136
  ### In-code
126
137
 
127
- > <img src=".github/assets/readme/node-js.svg" width="24" />
128
- > <img src=".github/assets/readme/plus.svg" width="24" />
129
- > <img src=".github/assets/readme/bun.svg" width="24" />
138
+ #### Node.js and Bun
130
139
 
131
140
  ```ts
132
141
  import { poku } from 'poku';
133
142
 
134
- await poku(['targetDirA', 'targetDirB']);
143
+ await poku(['targetDir']);
135
144
  ```
136
145
 
137
- > <img src=".github/assets/readme/deno.svg" width="24" />
146
+ #### Deno
138
147
 
139
148
  ```ts
140
149
  import { poku } from 'npm:poku';
141
150
 
142
- await poku(['targetDirA', 'targetDirB']);
151
+ await poku(['targetDir']);
143
152
  ```
144
153
 
145
154
  ### CLI
@@ -147,454 +156,24 @@ await poku(['targetDirA', 'targetDirB']);
147
156
  > <img src=".github/assets/readme/node-js.svg" width="24" />
148
157
 
149
158
  ```bash
150
- npx poku targetDirA,targetDirB
159
+ npx poku targetDir
151
160
  ```
152
161
 
153
162
  > <img src=".github/assets/readme/bun.svg" width="24" />
154
163
 
155
164
  ```bash
156
- bun poku targetDirA,targetDirB
165
+ bun poku targetDir
157
166
  ```
158
167
 
159
168
  > <img src=".github/assets/readme/deno.svg" width="24" />
160
169
 
161
170
  ```bash
162
- deno run npm:poku targetDirA,targetDirB
171
+ deno run npm:poku targetDir
163
172
  ```
164
173
 
165
174
  ---
166
175
 
167
- ## Documentation
168
-
169
- > Website in Progress 🧑🏻‍🔧
170
- >
171
- > Initially, the documentation is based on **Node.js** usage, but you can use all the options normally for both **Bun** and **Deno**.
172
-
173
- ### `poku(targetDirs: string | string[])`
174
-
175
- #### Include directories
176
-
177
- - **in-code**
178
-
179
- ```ts
180
- poku('targetDir');
181
- ```
182
-
183
- ```ts
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
195
- ```
196
-
197
- ```bash
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'
207
- ```
208
-
209
- ```bash
210
- npx poku --include='targetDirA,targetDirB'
211
- ```
212
-
213
- ---
214
-
215
- ### `poku(targetDirs: string | string[], configs?: Configs)`
216
-
217
- #### `parallel: boolean`
218
-
219
- Determines the mode of test execution across **sequential** or **parallel** modes.
220
-
221
- - **in-code**
222
-
223
- ```ts
224
- /**
225
- * @default
226
- *
227
- * Sequential mode
228
- */
229
-
230
- poku(['...'], {
231
- parallel: false,
232
- });
233
- ```
234
-
235
- ```ts
236
- /**
237
- * Parallel mode
238
- */
239
-
240
- poku(['...'], {
241
- parallel: true,
242
- });
243
- ```
244
-
245
- - **CLI**
246
-
247
- > _Since **1.2.0**_
248
-
249
- ```bash
250
- # Parallel mode
251
-
252
- npx poku --parallel ./test
253
- ```
254
-
255
- ---
256
-
257
- #### `platform: "node" | "bun" | "deno"`
258
-
259
- > _Since **1.2.0**_
260
-
261
- By default, **Poku** tries to identify the platform automatically, but you can set it manually:
262
-
263
- - **in-code**
264
-
265
- ```ts
266
- /**
267
- * Force Node.js (or tsx for TypeScript)
268
- *
269
- * @default 'node'
270
- */
271
-
272
- poku('...', {
273
- platform: 'node',
274
- });
275
- ```
276
-
277
- ```ts
278
- /**
279
- * Force Bun
280
- */
281
-
282
- poku('...', {
283
- platform: 'bun',
284
- });
285
- ```
286
-
287
- ```ts
288
- /**
289
- * Force Deno
290
- */
291
-
292
- poku('...', {
293
- platform: 'deno',
294
- });
295
- ```
296
-
297
- - **CLI**
298
-
299
- ```bash
300
- # Normal
301
-
302
- npx poku --platform=node ./test
303
- bun poku --platform=bun ./test
304
- deno run npm:poku --platform=deno ./test
305
- ```
306
-
307
- ```bash
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
314
-
315
- # ...
316
- ```
317
-
318
- ---
319
-
320
- #### `filter: RegExp`
321
-
322
- By default, **Poku** searches for _`.test.`_ files, but you can customize it using the `filter` option.
323
-
324
- > Filter by path using **Regex** to match only the files that should be performed.
325
-
326
- - **in-code**
327
-
328
- ```ts
329
- /**
330
- * @default
331
- *
332
- * Testing all `*.test.*` files.
333
- */
334
-
335
- poku(['...'], {
336
- filter: /\.test\./,
337
- });
338
- ```
339
-
340
- ```ts
341
- /**
342
- * Testing all `ts`, `js`, `mts` and `mjs` files
343
- */
344
-
345
- poku(['...'], {
346
- filter: /\.(m)?(j|t)s$/,
347
- // filter: /\.(js|ts|mjs|mts)$/,
348
- });
349
- ```
350
-
351
- - **CLI**
352
-
353
- ```bash
354
- # Testing only a specific file
355
-
356
- npx poku --filter='some-file' ./test
357
- ```
358
-
359
- ```bash
360
- # Testing only a specific file
361
-
362
- npx poku --filter='some-file|other-file' ./test
363
- ```
364
-
365
- ```bash
366
- # Testing only paths that contains "unit"
367
-
368
- npx poku --filter='unit' ./test
369
- ```
370
-
371
- - **Environment Variable**
372
-
373
- > By using `FILTER` from **Environment Variable**, it will overwrite the `filter` option.
374
-
375
- ```bash
376
- # Testing only a specific file
377
-
378
- FILTER='some-file' npx poku ./test
379
- ```
380
-
381
- ```bash
382
- # Testing only a specific file
383
-
384
- FILTER='some-file|other-file' npx poku ./test
385
- ```
386
-
387
- ```bash
388
- # Testing only paths that contains "unit"
389
-
390
- FILTER='unit' npx poku ./test
391
- ```
392
-
393
- ---
394
-
395
- #### `exclude: RegExp | RegExp[]`
396
-
397
- > Exclude by path using Regex to match only the files that should be performed.
398
- >
399
- > _Since **1.2.0**_
400
-
401
- - **in-code**:
402
-
403
- ```ts
404
- /**
405
- * Excluding directories from tests
406
- */
407
-
408
- poku(['...'], {
409
- exclude: /\/(helpers|tools)\//,
410
- });
411
- ```
412
-
413
- ```ts
414
- /**
415
- * Excluding directories from tests
416
- */
417
-
418
- poku(['...'], {
419
- exclude: [/\/helpers\//, /\/tools\//],
420
- });
421
- ```
422
-
423
- ```ts
424
- /**
425
- * Excluding specific files from tests
426
- */
427
-
428
- poku(['...'], {
429
- exclude: /(index|common).test.ts/,
430
- });
431
- ```
432
-
433
- ```ts
434
- /**
435
- * Excluding specific files from tests
436
- */
437
-
438
- poku(['...'], {
439
- exclude: [/index.test.ts/, /common.test.ts/],
440
- });
441
- ```
442
-
443
- ```ts
444
- /**
445
- * Excluding directories and files from tests
446
- */
447
-
448
- poku(['...'], {
449
- exclude: /\/(helpers|tools)\/|(index|common).test.ts/,
450
- });
451
- ```
452
-
453
- ```ts
454
- /**
455
- * Excluding directories and files from tests
456
- */
457
-
458
- poku(['...'], {
459
- exclude: [/\/helpers\//, /\/tools\//, /index.test.ts/, /common.test.ts/],
460
- });
461
- ```
462
-
463
- - **CLI**
464
-
465
- ```bash
466
- # Excluding directories and files from tests
467
-
468
- npx poku --exclude='some-file-or-dir' ./test
469
- ```
470
-
471
- ```bash
472
- # Excluding directories and files from tests
473
-
474
- npx poku --exclude='some-file-or-dir|other-file-or-dir' ./test
475
- ```
476
-
477
- ---
478
-
479
- #### `quiet`
480
-
481
- Perform tests with no logs.
482
-
483
- > This option overwrites all `log` settings by exiting with code and no logs (see bellow).
484
-
485
- - **in-code**
486
-
487
- ```ts
488
- poku(['...'], {
489
- quiet: true,
490
- });
491
- ```
492
-
493
- - **CLI**
494
-
495
- > _Since **1.3.1**_
496
-
497
- ```bash
498
- npx poku --quiet ./test
499
- ```
500
-
501
- ---
502
-
503
- #### `log`
504
-
505
- ##### `success`
506
-
507
- By default **Poku** doesn't shows succes logs, but you can enable it:
508
-
509
- - **in-code**
510
-
511
- ```ts
512
- poku(['...'], {
513
- log: {
514
- success: true,
515
- },
516
- });
517
- ```
518
-
519
- - **CLI**
520
-
521
- > _Since **1.3.1**_
522
-
523
- ```bash
524
- npx poku --log-success ./test
525
- ```
526
-
527
- ---
528
-
529
- ### Assert
530
-
531
- > _Since **1.3.0**_
532
- >
533
- > [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url] compatible.
534
-
535
- **Poku** includes the `assert` method native from [**Node.js**][node-version-url], keeping everything as it is, but providing human readability.<br/>
536
- It supports both [**Bun**][bun-version-url] and [**Deno**][deno-version-url].
537
-
538
- #### Migrating to **Poku**'s assert
539
-
540
- _But only if you want to, of course._
541
-
542
- > <img src=".github/assets/readme/node-js.svg" width="24" />
543
- > <img src=".github/assets/readme/plus.svg" width="24" />
544
- > <img src=".github/assets/readme/bun.svg" width="24" />
545
-
546
- ```diff
547
- - import assert from 'node:assert';
548
- + import { assert } from 'poku';
549
-
550
- assert(true);
551
- ```
552
-
553
- > <img src=".github/assets/readme/deno.svg" width="24" />
554
-
555
- ```diff
556
- - import assert from 'node:assert';
557
- + import { assert } from 'npm:poku';
558
-
559
- assert(true);
560
- ```
561
-
562
- #### Available methods
563
-
564
- - `assert(value[, message])`
565
- - `assert.deepEqual(actual, expected[, message])`
566
- - `assert.deepStrictEqual(actual, expected[, message])`
567
- - `assert.doesNotMatch(string, regexp[, message])`
568
- - `assert.doesNotReject(asyncFn[, error][, message])`
569
- - `assert.doesNotThrow(fn[, error][, message])`
570
- - `assert.equal(actual, expected[, message])`
571
- - `assert.fail([message])`
572
- - `assert.ifError(value)`
573
- - `assert.match(string, regexp[, message])`
574
- - `assert.notDeepEqual(actual, expected[, message])`
575
- - `assert.notDeepStrictEqual(actual, expected[, message])`
576
- - `assert.notEqual(actual, expected[, message])`
577
- - `assert.notStrictEqual(actual, expected[, message])`
578
- - `assert.ok(value[, message])`
579
- - `assert.rejects(asyncFn[, error][, message])`
580
- - `assert.strictEqual(actual, expected[, message])`
581
- - `assert.throws(fn[, error][, message])`
582
-
583
- You can follow the [**assert documentation**](https://nodejs.org/api/assert.html) from **Node.js**'s documentation.
584
-
585
- ---
586
-
587
- ### `listFiles(targetDir: string, configs?: ListFilesConfigs)`
588
-
589
- > _Since **1.2.0**_
590
-
591
- Returns all files in a directory, independent of their depth.
592
-
593
- ```ts
594
- listFiles('some-dir');
595
- ```
596
-
597
- - You can use the `filter` and `exclude` options, as well as they are for **`poku`** method.
176
+ To see the detailed documentation, please visit the [**Documentation**](https://poku.dev/docs/category/documentation) section in the [**Poku**'s website](https://poku.dev).
598
177
 
599
178
  ---
600
179
 
@@ -9,14 +9,19 @@ export type Configs = {
9
9
  */
10
10
  noExit?: boolean;
11
11
  /**
12
+ * @deprecated
12
13
  * Customize `stdout` options.
13
14
  */
14
15
  log?: {
15
16
  /**
17
+ * @deprecated
18
+ *
16
19
  * @default false
17
20
  */
18
21
  success?: boolean;
19
22
  /**
23
+ * @deprecated
24
+ *
20
25
  * @default true
21
26
  */
22
27
  fail?: boolean;
@@ -26,6 +31,12 @@ export type Configs = {
26
31
  *
27
32
  * @default false
28
33
  */
34
+ debug?: boolean;
35
+ /**
36
+ * This option overwrites the `debug` settings.
37
+ *
38
+ * @default false
39
+ */
29
40
  quiet?: boolean;
30
41
  /**
31
42
  * Determines the mode of test execution.