poku 1.21.0 โ†’ 1.23.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
@@ -1,20 +1,20 @@
1
1
  <div align="center">
2
- <img width="125" height="125" alt="Logo" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/poku.svg">
2
+ <img height="180" alt="Poku's Logo" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/poku.svg">
3
3
 
4
4
  # Poku
5
5
 
6
6
  Enjoying **Poku**? Give him a star to show your support ๐ŸŒŸ
7
7
 
8
- [![NPM Downloads][downloads-image]][downloads-url]
9
- [![Coverage][coverage-image]][coverage-url]
10
- [![License][license-image]][license-url]<br />
11
- [![GitHub Workflow Status (with event)][ci-linux-image]][ci-linux-url]
12
- [![GitHub Workflow Status (with event)][ci-osx-image]][ci-osx-url]
13
- [![GitHub Workflow Status (with event)][ci-windows-image]][ci-windows-url]
8
+ [![NPM Downloads](https://img.shields.io/npm/dt/poku.svg?logo=npm&logoColor=white&color=1e90ff)](https://www.npmjs.com/package/poku)
9
+ [![Coverage](https://img.shields.io/codecov/c/github/wellwelwel/poku)](https://app.codecov.io/github/wellwelwel/poku)
10
+ [![License](https://img.shields.io/npm/l/poku?maxAge=2592000&color=9c88ff)](https://github.com/wellwelwel/poku/blob/main/LICENSE)<br />
11
+ [![GitHub Workflow Status (Linux)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&label=&branch=main&logo=ubuntu&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain)
12
+ [![GitHub Workflow Status (OSX)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-osx.yml?event=push&label=&branch=main&logo=apple&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-osx.yml?query=branch%3Amain)
13
+ [![GitHub Workflow Status (Windows)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-windows.yml?event=push&label=&branch=main&logo=iterm2&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-windows.yml?query=branch%3Amain)
14
14
 
15
15
  ---
16
16
 
17
- ๐Ÿท [Documentation](https://poku.io)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿงช [Examples](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿ”ฌ [Compare the Most Popular Test Runners](https://poku.io/docs/comparing)
17
+ ๐Ÿท [Website](https://poku.io/)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿ“˜ [Documentation](https://poku.io/docs/category/documentation)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿงช [Examples](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;โ€ข&nbsp;&nbsp;</span>๐Ÿง‘๐Ÿปโ€๐ŸŽ“ [Quick Tutorials](https://poku.io/docs/category/quick-tutorials)
18
18
 
19
19
  </div>
20
20
 
@@ -22,35 +22,32 @@ Enjoying **Poku**? Give him a star to show your support ๐ŸŒŸ
22
22
 
23
23
  ## Why does Poku exist?
24
24
 
25
- ๐Ÿ’ก **Poku** makes testing easy and brings the [native **JavaScript** syntax back to tests](https://poku.io/docs/philosophy), letting you to write tests intuitively โ€” _just like in real **JavaScript** code_.
25
+ ๐Ÿ’ก **Poku** makes testing easy and brings the [native **JavaScript** syntax back to tests](https://poku.io/docs/philosophy#javascript-essence-for-tests-), letting you to write tests intuitively.
26
26
 
27
- <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> No configurations<br />
27
+ <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> _No configurations_<br />
28
28
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><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 />
29
29
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><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 />
30
30
 
31
- <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easier and Less Verbose<br />
32
- <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> [**Node.js**][node-version-url] familiar **API**<br />
33
- <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Instantly re-run related tests in `watch` mode<br />
31
+ <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> _Easier and Less Verbose_<br />
34
32
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run **CJS** (**CommonJS**) files directly with [**Deno**][deno-version-url]<br />
35
- <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **containers**, **servers**, **services**, **processes**, and **ports**<br />
33
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **containers**, **servers**, **processes**, and **ports**<br />
36
34
 
37
- <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Safety and Reliability<br />
35
+ <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> _Safety and Reliability_<br />
38
36
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> High **isolation** level per file<br />
39
37
  <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> **Performant** and **lightweight**<br />
40
- <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Compatible with **coverage** tools
41
38
 
42
39
  ---
43
40
 
44
41
  ## Quickstart
45
42
 
46
- ### Install
43
+ ### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Install
47
44
 
48
45
  <table>
49
46
  <tr>
50
- <td><blockquote><b>Node.js</b</blockquote></td>
51
- <td><blockquote><b>TypeScript + Node.js</b</blockquote></td>
52
- <td><blockquote><b>Bun</b</blockquote></td>
53
- <td><blockquote><b>Deno</b</blockquote></td>
47
+ <td><blockquote><i>Node.js</i></blockquote></td>
48
+ <td><blockquote><i>TypeScript (Node.js)</i></blockquote></td>
49
+ <td><blockquote><i>Bun</i></blockquote></td>
50
+ <td><blockquote><i>Deno</i></blockquote></td>
54
51
  </tr>
55
52
  <tr>
56
53
  <td width="400">
@@ -84,7 +81,9 @@ deno add npm:poku
84
81
  </tr>
85
82
  </table>
86
83
 
87
- ### Test
84
+ ---
85
+
86
+ ### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Test
88
87
 
89
88
  <table>
90
89
  <tr>
@@ -105,13 +104,15 @@ assert(true, 'Poku will describe it ๐Ÿท');
105
104
  </tr>
106
105
  </table>
107
106
 
108
- ### Run
107
+ ---
108
+
109
+ ### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run
109
110
 
110
111
  <table>
111
112
  <tr>
112
- <td><blockquote><b>Node.js (and TypeScript)</b</blockquote></td>
113
- <td><blockquote><b>Bun</b</blockquote></td>
114
- <td><blockquote><b>Deno</b</blockquote></td>
113
+ <td><blockquote><i>Node.js (and TypeScript)</i></blockquote></td>
114
+ <td><blockquote><i>Bun</i></blockquote></td>
115
+ <td><blockquote><i>Deno</i></blockquote></td>
115
116
  </tr>
116
117
  <tr>
117
118
  <td width="400">
@@ -138,32 +139,102 @@ deno run npm:poku
138
139
  </tr>
139
140
  </table>
140
141
 
141
- > Try the flag `--parallel` to run tests in parallel.
142
-
143
- - That's it ๐ŸŽ‰
144
-
145
142
  ---
146
143
 
147
- ## Available Methods
144
+ ## Features
148
145
 
149
146
  ### Essentials
150
147
 
151
- - [**poku**](https://poku.io/docs/category/-poku) _(test runner)_
152
- - [**assert**](https://poku.io/docs/documentation/assert) _(test assertion)_
148
+ <table>
149
+ <tr>
150
+ <th width="250">Name</th>
151
+ <th width="800">Description</th>
152
+ </tr>
153
+ <tr>
154
+ <td><a href="https://poku.io/docs/category/-poku">poku</a></td>
155
+ <td>๐Ÿงช Test runner.</td>
156
+ </tr>
157
+ <tr>
158
+ <td><a href="https://poku.io/docs/documentation/assert">assert</a></td>
159
+ <td>๐Ÿ”ฌ Test assertion <i>(<strong>Node.js</strong> familiar <strong>API</strong>)</i>.</td>
160
+ </tr>
161
+ </table>
153
162
 
154
163
  ### Helpers
155
164
 
156
- - [**test**](https://poku.io/docs/documentation/helpers/test), [**describe**](https://poku.io/docs/documentation/helpers/describe) and [**it**](https://poku.io/docs/documentation/helpers/it) _(organize, group, and isolate tests)_
157
- - [**watch**](https://poku.io/docs/documentation/poku/options/watch) _(watch for changes and re-run related test files)_
158
- - [**beforeEach**](https://poku.io/docs/category/-before-and-after-each) and [**afterEach**](https://poku.io/docs/category/-before-and-after-each) _(hooks for test setup and teardown)_
159
- - [**docker**](https://poku.io/docs/documentation/helpers/containers) _(build, start, compose, stop, remove, and test containers)_
160
- - [**startScript**](https://poku.io/docs/documentation/helpers/startScript) _(run **package.json** scripts in background)_
161
- - [**startService**](https://poku.io/docs/documentation/helpers/startService) _(run files in background)_
162
- - [**kill**](https://poku.io/docs/documentation/helpers/processes/kill) _(terminate ports, port ranges, and PIDs)_
163
- - [**waitForPort**](https://poku.io/docs/documentation/helpers/processes/wait-for-port) _(wait for specified ports to become active)_
164
- - [**waitForExpectedResult**](https://poku.io/docs/documentation/helpers/processes/wait-for-expected-result) _(retry until an expected result or times out)_
165
- - [**getPIDs**](https://poku.io/docs/documentation/helpers/processes/get-pids) _(debug processes IDs using ports and port ranges)_
166
- - _and much more_ ๐Ÿ‘‡๐Ÿป
165
+ <table>
166
+ <tr>
167
+ <th width="250">Name</th>
168
+ <th width="800">Description</th>
169
+ </tr>
170
+ <tr>
171
+ <td><a href="https://poku.io/docs/documentation/helpers/test">test</a> โ€ข <a href="https://poku.io/docs/documentation/helpers/describe">describe</a> โ€ข <a href="https://poku.io/docs/documentation/helpers/it">it</a></td>
172
+ <td>๐Ÿคน๐Ÿปโ€โ™€๏ธ Organize, group, and isolate tests.</td>
173
+ </tr>
174
+ <tr>
175
+ <td><a href="https://poku.io/docs/documentation/helpers/env">envFile</a></td>
176
+ <td>โš™๏ธ Process an environment file <i>(out-of-box)</i>.</td>
177
+ </tr>
178
+ <tr>
179
+ <td><a href="https://poku.io/docs/category/-before-and-after-each">beforeEach</a> โ€ข <a href="https://poku.io/docs/category/-before-and-after-each">afterEach</a></td>
180
+ <td>๐Ÿƒ Hooks for test setup and teardown.</td>
181
+ </tr>
182
+ <tr>
183
+ <td><a href="https://poku.io/docs/documentation/helpers/startScript">startScript</a></td>
184
+ <td>๐ŸŒ Run package.json scripts in background.</td>
185
+ </tr>
186
+ <tr>
187
+ <td><a href="https://poku.io/docs/documentation/helpers/startService">startService</a></td>
188
+ <td>๐ŸŒ Run files in background.</td>
189
+ </tr>
190
+ <tr>
191
+ <td><a href="https://poku.io/docs/documentation/helpers/containers">docker</a></td>
192
+ <td>๐Ÿณ Build, start, compose, stop, remove, and test containers.</td>
193
+ </tr>
194
+ <tr>
195
+ <td><a href="https://poku.io/docs/documentation/helpers/processes/kill">kill</a></td>
196
+ <td>๐Ÿ”Œ Terminate ports, port ranges, and PIDs.</td>
197
+ </tr>
198
+ <tr>
199
+ <td><a href="https://poku.io/docs/documentation/helpers/processes/wait-for-port">waitForPort</a></td>
200
+ <td>๐Ÿ˜ด Wait for specified ports to become active.</td>
201
+ </tr>
202
+ <tr>
203
+ <td><a href="https://poku.io/docs/documentation/helpers/processes/wait-for-expected-result">waitForExpectedResult</a></td>
204
+ <td>๐Ÿฅฑ Retry until an expected result or times out.</td>
205
+ </tr>
206
+ <tr>
207
+ <td><a href="https://poku.io/docs/documentation/helpers/skip">skip</a></td>
208
+ <td>โญ๏ธ Skip tests when necessary.</td>
209
+ </tr>
210
+ <tr>
211
+ <td><a href="https://poku.io/docs/documentation/helpers/processes/get-pids">getPIDs</a></td>
212
+ <td>๐Ÿ•ต๐Ÿป Debug processes IDs using ports and port ranges.</td>
213
+ </tr>
214
+ </table>
215
+
216
+ ### Common Options
217
+
218
+ <table>
219
+ <tr>
220
+ <th width="250">Name</th>
221
+ <th width="800">Description</th>
222
+ </tr>
223
+ <tr>
224
+ <td><a href="https://poku.io/docs/documentation/poku/options/watch">watch</a></td>
225
+ <td>๐Ÿฟ Watch for changes and re-run related test files.</td>
226
+ </tr>
227
+ <tr>
228
+ <td><a href="https://poku.io/docs/documentation/poku/options/parallel">parallel</a></td>
229
+ <td>๐Ÿƒ๐Ÿปโ€โ™€๏ธ Run tests in parallel.</td>
230
+ </tr>
231
+ <tr>
232
+ <td><a href="https://poku.io/docs/documentation/poku/options/debug">debug</a></td>
233
+ <td>๐Ÿ•ต๐Ÿป Shows all logs.</td>
234
+ </tr>
235
+ </table>
236
+
237
+ > _and much more_ ๐Ÿ‘‡๐Ÿป
167
238
 
168
239
  ---
169
240
 
@@ -173,6 +244,19 @@ To see the detailed documentation, please visit the [**Documentation**](https://
173
244
 
174
245
  ---
175
246
 
247
+ ### Tutorials
248
+
249
+ **Poku** offers _mini-lessons_ for different users needs in the [**Quick Tutorials**](https://poku.io/docs/category/quick-tutorials) section.
250
+
251
+ ---
252
+
253
+ ### Common Issues
254
+
255
+ - [Avoiding conflicts in environments with multiple platforms installed](https://poku.io/docs/tutorials/cross-platform#recommendations).
256
+ - [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises).
257
+
258
+ ---
259
+
176
260
  ## Contributing
177
261
 
178
262
  See the [**Contributing Guide**](https://github.com/wellwelwel/poku/blob/main/CONTRIBUTING.md) and please follow our [**Code of Conduct**](https://github.com/wellwelwel/poku/blob/main/CODE_OF_CONDUCT.md) ๐Ÿš€
@@ -181,7 +265,7 @@ See the [**Contributing Guide**](https://github.com/wellwelwel/poku/blob/main/CO
181
265
 
182
266
  ## Security Policy
183
267
 
184
- [![GitHub Workflow Status (with event)][ql-image]][ql-url]
268
+ [![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&label=&branch=main&logo=github&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain)
185
269
 
186
270
  Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/SECURITY.md).
187
271
 
@@ -191,7 +275,7 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/
191
275
 
192
276
  ### Performance
193
277
 
194
- **Poku** is [continuously tested](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml) to ensure the following expectations:
278
+ **Poku** is [continuously tested](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml) to ensure the following expectations for basic usage:
195
279
 
196
280
  - **~4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0)
197
281
  - **~3x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v1.6.0)
@@ -215,8 +299,11 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/
215
299
 
216
300
  ### Limitations
217
301
 
218
- - Although it has no external dependencies, **Poku** is not _all-in-one_, so it doesn't have features such as _mocks_, _spies_, _coverage reports_, etc., where you can use your favorite packages or native solutions.
219
- - **Poku** community is gradually building up.
302
+ - Although it has no external dependencies, **Poku** is not _all-in-one_, so it doesn't have integrated features such as _mocks_, _spies_, _coverage reports_, etc., where you can use your favorite packages or native solutions.
303
+ - See a [mock example](https://poku.io/docs/category/mock).
304
+ - **Poku** doesn't render components (such as **Angular**, **React**, etc.).
305
+ - See an [_end-to-end_ test example](https://poku.io/docs/examples/browser/react).
306
+ - Our community is gradually building up.
220
307
 
221
308
  ---
222
309
 
@@ -235,18 +322,3 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/
235
322
  [node-version-url]: https://github.com/nodejs/node
236
323
  [bun-version-url]: https://github.com/oven-sh/bun
237
324
  [deno-version-url]: https://github.com/denoland/deno
238
- [typescript-url]: https://github.com/microsoft/TypeScript
239
- [ci-linux-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain
240
- [ci-linux-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&label=&branch=main&logo=ubuntu&logoColor=white
241
- [ci-osx-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-osx.yml?query=branch%3Amain
242
- [ci-osx-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-osx.yml?event=push&label=&branch=main&logo=apple&logoColor=white
243
- [ci-windows-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-windows.yml?query=branch%3Amain
244
- [ci-windows-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-windows.yml?event=push&label=&branch=main&logo=windows&logoColor=white
245
- [ql-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain
246
- [ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&label=&branch=main&logo=github&logoColor=white
247
- [coverage-image]: https://img.shields.io/codecov/c/github/wellwelwel/poku
248
- [coverage-url]: https://app.codecov.io/github/wellwelwel/poku
249
- [downloads-image]: https://img.shields.io/npm/dt/poku.svg?logo=npm&logoColor=white&color=1e90ff
250
- [downloads-url]: https://www.npmjs.com/package/poku
251
- [license-url]: https://github.com/wellwelwel/poku/blob/main/LICENSE
252
- [license-image]: https://img.shields.io/npm/l/poku?maxAge=2592000&color=9c88ff
package/lib/bin/index.js CHANGED
@@ -12,6 +12,7 @@ const files_js_1 = require("../configs/files.js");
12
12
  const get_runtime_js_1 = require("../parsers/get-runtime.js");
13
13
  const format_js_1 = require("../services/format.js");
14
14
  const kill_js_1 = require("../modules/helpers/kill.js");
15
+ const env_js_1 = require("../modules/helpers/env.js");
15
16
  const map_tests_js_1 = require("../services/map-tests.js");
16
17
  const watch_js_1 = require("../services/watch.js");
17
18
  const poku_js_1 = require("../modules/essentials/poku.js");
@@ -41,6 +42,7 @@ const quiet = (0, get_arg_js_1.hasArg)('quiet');
41
42
  const debug = (0, get_arg_js_1.hasArg)('debug');
42
43
  const failFast = (0, get_arg_js_1.hasArg)('fail-fast');
43
44
  const watchMode = (0, get_arg_js_1.hasArg)('watch');
45
+ const hasEnvFile = (0, get_arg_js_1.hasArg)('env-file');
44
46
  const concurrency = parallel
45
47
  ? Number((0, get_arg_js_1.getArg)('concurrency')) || undefined
46
48
  : undefined;
@@ -62,6 +64,10 @@ if (killPID) {
62
64
  const PIDs = killPID.split(',').map(Number);
63
65
  tasks.push(kill_js_1.kill.pid(PIDs));
64
66
  }
67
+ if (hasEnvFile) {
68
+ const envFilePath = (0, get_arg_js_1.getArg)('env-file');
69
+ tasks.push((0, env_js_1.envFile)(envFilePath));
70
+ }
65
71
  const options = {
66
72
  platform: (0, get_runtime_js_1.platformIsValid)(platform) ? platform : undefined,
67
73
  filter: filter ? new RegExp((0, list_files_js_1.escapeRegExp)(filter)) : undefined,
@@ -1,4 +1,5 @@
1
1
  export declare const results: {
2
2
  success: number;
3
3
  fail: number;
4
+ skipped: number;
4
5
  };
@@ -4,4 +4,5 @@ exports.results = void 0;
4
4
  exports.results = {
5
5
  success: 0,
6
6
  fail: 0,
7
+ skipped: 0,
7
8
  };
@@ -24,7 +24,7 @@ export declare const assert: ((value: unknown, message?: ProcessAssertionOptions
24
24
  notDeepStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => void;
25
25
  match: (value: string, regExp: RegExp, message?: ProcessAssertionOptions["message"]) => void;
26
26
  ifError: (value: unknown, message?: ProcessAssertionOptions["message"]) => void;
27
- fail: (message?: ProcessAssertionOptions["message"]) => void;
27
+ fail: (message?: ProcessAssertionOptions["message"]) => never;
28
28
  rejects: typeof rejects;
29
29
  };
30
30
  export {};
@@ -94,6 +94,7 @@ const fail = (message) => {
94
94
  defaultMessage: 'Test failed intentionally',
95
95
  hideDiff: true,
96
96
  });
97
+ process.exit(1);
97
98
  };
98
99
  function doesNotThrow(block, errorOrMessage, message) {
99
100
  (0, assert_js_1.processAssert)(() => {
@@ -24,7 +24,7 @@ export declare const assertPromise: ((value: unknown, message?: ProcessAssertion
24
24
  notDeepStrictEqual: (actual: unknown, expected: unknown, message?: ProcessAssertionOptions["message"]) => Promise<void>;
25
25
  match: (value: string, regExp: RegExp, message?: ProcessAssertionOptions["message"]) => Promise<void>;
26
26
  ifError: (value: unknown, message?: ProcessAssertionOptions["message"]) => Promise<void>;
27
- fail: (message?: ProcessAssertionOptions["message"]) => Promise<void>;
27
+ fail: (message?: ProcessAssertionOptions["message"]) => Promise<never>;
28
28
  rejects: typeof rejects;
29
29
  };
30
30
  export {};
@@ -100,6 +100,7 @@ const fail = (message) => __awaiter(void 0, void 0, void 0, function* () {
100
100
  defaultMessage: 'Test failed intentionally',
101
101
  hideDiff: true,
102
102
  });
103
+ process.exit(1);
103
104
  });
104
105
  function doesNotThrow(block, errorOrMessage, message) {
105
106
  return __awaiter(this, void 0, void 0, function* () {
@@ -0,0 +1,2 @@
1
+ /** Reads an environment file and sets the environment variables. */
2
+ export declare const envFile: (filePath?: string) => Promise<void>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.envFile = void 0;
13
+ /* c8 ignore start */ // ?
14
+ const fs_js_1 = require("../../polyfills/fs.js");
15
+ const list_files_js_1 = require("./list-files.js");
16
+ const env_js_1 = require("../../services/env.js");
17
+ const regex = {
18
+ comment: /^\s*#/,
19
+ };
20
+ /** Reads an environment file and sets the environment variables. */
21
+ const envFile = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (filePath = '.env') {
22
+ /* c8 ignore stop */
23
+ const mapEnv = new Map();
24
+ const env = yield (0, fs_js_1.readFile)((0, list_files_js_1.sanitizePath)(filePath), 'utf8');
25
+ const lines = env
26
+ .split('\n')
27
+ .map((line) => (0, env_js_1.removeComments)(line.trim()))
28
+ .filter((line) => line.length > 0 && !regex.comment.test(line));
29
+ for (const line of lines) {
30
+ const parsedLine = (0, env_js_1.parseEnvLine)(line);
31
+ if (parsedLine) {
32
+ const { arg, value } = parsedLine;
33
+ mapEnv.set(arg, value ? (0, env_js_1.resolveEnvVariables)(value, process.env) : value);
34
+ }
35
+ }
36
+ for (const [arg, value] of mapEnv) {
37
+ process.env[arg] = value;
38
+ }
39
+ });
40
+ exports.envFile = envFile;
@@ -20,7 +20,7 @@ const exit = (code, quiet) => {
20
20
  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
21
  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
22
  write_js_1.Write.hr();
23
- write_js_1.Write.log(`${(0, format_js_1.format)(` PASS โ€บ ${poku_js_1.results.success} `).bg('green')} ${(0, format_js_1.format)(` FAIL โ€บ ${poku_js_1.results.fail} `).bg(poku_js_1.results.fail === 0 ? 'grey' : 'red')}`);
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') : ''}`);
24
24
  write_js_1.Write.hr();
25
25
  }
26
26
  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 @@
1
+ export declare const skip: (message?: string) => never;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.skip = void 0;
4
+ const node_process_1 = require("process");
5
+ const write_js_1 = require("../../services/write.js");
6
+ const format_js_1 = require("../../services/format.js");
7
+ const skip = (message) => {
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
+ const FILE = node_process_1.env.FILE;
10
+ if (message) {
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}`)
14
+ .info()
15
+ .bold());
16
+ }
17
+ (0, node_process_1.exit)(0);
18
+ };
19
+ exports.skip = skip;
@@ -52,7 +52,6 @@ const waitForExpectedResult = (callback, expectedResult, options) => __awaiter(v
52
52
  /* c8 ignore stop */
53
53
  yield (0, exports.sleep)(delay);
54
54
  const startTime = Date.now();
55
- // eslint-disable-next-line no-constant-condition
56
55
  while (true) {
57
56
  const result = yield callback();
58
57
  if (typeof expectedResult === 'function') {
@@ -3,6 +3,8 @@ export { assert } from './essentials/assert.js';
3
3
  export { test } from './helpers/test.js';
4
4
  export { describe } from './helpers/describe.js';
5
5
  export { it } from './helpers/it.js';
6
+ export { envFile } from './helpers/env.js';
7
+ export { skip } from './helpers/skip.js';
6
8
  export { beforeEach, afterEach } from './helpers/each.js';
7
9
  export { docker } from './helpers/container.js';
8
10
  export { startScript, startService } from './helpers/create-service.js';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertPromise = 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.it = exports.describe = exports.test = exports.assert = exports.poku = void 0;
3
+ exports.assertPromise = 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.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,6 +11,10 @@ var describe_js_1 = require("./helpers/describe.js");
11
11
  Object.defineProperty(exports, "describe", { enumerable: true, get: function () { return describe_js_1.describe; } });
12
12
  var it_js_1 = require("./helpers/it.js");
13
13
  Object.defineProperty(exports, "it", { enumerable: true, get: function () { return it_js_1.it; } });
14
+ var env_js_1 = require("./helpers/env.js");
15
+ Object.defineProperty(exports, "envFile", { enumerable: true, get: function () { return env_js_1.envFile; } });
16
+ var skip_js_1 = require("./helpers/skip.js");
17
+ Object.defineProperty(exports, "skip", { enumerable: true, get: function () { return skip_js_1.skip; } });
14
18
  var each_js_1 = require("./helpers/each.js");
15
19
  Object.defineProperty(exports, "beforeEach", { enumerable: true, get: function () { return each_js_1.beforeEach; } });
16
20
  Object.defineProperty(exports, "afterEach", { enumerable: true, get: function () { return each_js_1.afterEach; } });
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parserOutput = exports.isDebug = exports.isQuiet = void 0;
4
+ const poku_js_1 = require("../configs/poku.js");
4
5
  const regex = {
5
6
  newLine: /\n/,
6
7
  ansi: /u001b\[0m|\n/i,
8
+ skipped: /^"\\u001b\[94m\\u001b\[1mโ„น/i,
7
9
  };
8
10
  const isQuiet = (configs) => typeof (configs === null || configs === void 0 ? void 0 : configs.quiet) === 'boolean' && Boolean(configs === null || configs === void 0 ? void 0 : configs.quiet);
9
11
  exports.isQuiet = isQuiet;
@@ -13,6 +15,10 @@ exports.isDebug = isDebug;
13
15
  /* c8 ignore next */ // ?
14
16
  const parserOutput = (options) => {
15
17
  const { output, result, configs } = options;
18
+ const normalizedOutput = JSON.stringify(output);
19
+ if (regex.skipped.test(normalizedOutput)) {
20
+ ++poku_js_1.results.skipped;
21
+ }
16
22
  const debug = (0, exports.isDebug)(configs);
17
23
  const pad = (configs === null || configs === void 0 ? void 0 : configs.parallel) ? ' ' : ' ';
18
24
  const splittedOutput = output.split(regex.newLine);
@@ -0,0 +1,6 @@
1
+ export declare const removeComments: (input: string) => string;
2
+ export declare const parseEnvLine: (line: string) => {
3
+ arg: string;
4
+ value: string;
5
+ } | null;
6
+ export declare const resolveEnvVariables: (str: string, env: typeof process.env) => string;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveEnvVariables = exports.parseEnvLine = exports.removeComments = void 0;
4
+ /* c8 ignore next */ // ?
5
+ const removeComments = (input) => {
6
+ let output = '';
7
+ let quoteChar = '';
8
+ let inQuote = false;
9
+ for (let i = 0; i < input.length; i++) {
10
+ const char = input[i];
11
+ if (inQuote) {
12
+ output += char;
13
+ if (char === quoteChar && input[i - 1] !== '\\') {
14
+ inQuote = false;
15
+ }
16
+ }
17
+ else if (char === '"' || char === "'") {
18
+ inQuote = true;
19
+ quoteChar = char;
20
+ output += char;
21
+ }
22
+ else if (char === '#') {
23
+ break;
24
+ }
25
+ else {
26
+ output += char;
27
+ }
28
+ }
29
+ return output.trim();
30
+ };
31
+ exports.removeComments = removeComments;
32
+ /* c8 ignore net */ // ?
33
+ const parseEnvLine = (line) => {
34
+ const index = line.indexOf('=');
35
+ if (index === -1) {
36
+ return null;
37
+ }
38
+ const arg = line.substring(0, index).trim();
39
+ const value = line
40
+ .substring(index + 1)
41
+ .trim()
42
+ .replace(/^['"]|['"]$/g, '');
43
+ return { arg, value };
44
+ };
45
+ exports.parseEnvLine = parseEnvLine;
46
+ /* c8 ignore next */ // ?
47
+ const resolveEnvVariables = (str, env) => {
48
+ let result = '';
49
+ let i = 0;
50
+ while (i < str.length) {
51
+ if (str[i] === '$' && str[i + 1] === '{') {
52
+ i += 2;
53
+ let varName = '';
54
+ while (i < str.length && str[i] !== '}') {
55
+ varName += str[i];
56
+ i++;
57
+ }
58
+ i++;
59
+ result += env[varName] || '';
60
+ }
61
+ else {
62
+ result += str[i];
63
+ i++;
64
+ }
65
+ }
66
+ return result;
67
+ };
68
+ exports.resolveEnvVariables = resolveEnvVariables;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "1.21.0",
3
+ "version": "1.23.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",
@@ -26,7 +26,7 @@
26
26
  "node": ">=6.0.0",
27
27
  "bun": ">=1.0.0",
28
28
  "deno": ">=1.30.0",
29
- "typescript": ">=5.0.2"
29
+ "typescript": ">=4.7.2"
30
30
  },
31
31
  "scripts": {
32
32
  "test": "npm run test:parallel && npm run test:sequential",
@@ -59,11 +59,11 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@biomejs/biome": "1.8.3",
62
- "@types/node": "^20.14.9",
62
+ "@types/node": "^20.14.10",
63
63
  "c8": "^10.1.2",
64
64
  "packages-update": "^2.0.0",
65
65
  "shx": "^0.3.4",
66
- "tsx": "4.16.0",
66
+ "tsx": "4.16.2",
67
67
  "typescript": "^5.5.3"
68
68
  },
69
69
  "keywords": [
@@ -74,18 +74,10 @@
74
74
  "assertion",
75
75
  "testing",
76
76
  "node",
77
- "nodejs",
78
77
  "bun",
79
78
  "deno",
80
79
  "typescript",
81
80
  "tsx",
82
- "concurrent",
83
- "concurrency",
84
- "parallel",
85
- "parallelism",
86
- "sequential",
87
- "queue",
88
- "queuing",
89
81
  "run",
90
82
  "cli",
91
83
  "unit",
@@ -94,8 +86,6 @@
94
86
  "end-to-end",
95
87
  "tdd",
96
88
  "bdd",
97
- "isolate",
98
- "isolation",
99
89
  "watch",
100
90
  "jest",
101
91
  "mocha",
@@ -106,12 +96,13 @@
106
96
  "tap",
107
97
  "tape",
108
98
  "karma",
109
- "urun",
110
99
  "supertest",
100
+ "dotenv",
111
101
  "filter",
112
102
  "exclude",
113
103
  "list",
114
104
  "files",
105
+ "env",
115
106
  "kill",
116
107
  "container",
117
108
  "process",
@@ -122,11 +113,9 @@
122
113
  "esmodules",
123
114
  "esm",
124
115
  "mjs",
125
- "expect",
126
116
  "framework",
127
117
  "tool",
128
118
  "runtime",
129
- "poku",
130
- "pokujs"
119
+ "poku"
131
120
  ]
132
121
  }