poku 3.0.2 → 3.0.3-canary.24dfb51d

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.
Files changed (59) hide show
  1. package/README.md +23 -17
  2. package/lib/@types/poku.d.ts +12 -4
  3. package/lib/@types/shared-resources.d.ts +65 -0
  4. package/lib/bin/help.js +1 -0
  5. package/lib/bin/index.js +39 -7
  6. package/lib/bin/watch.js +1 -1
  7. package/lib/builders/assert.d.ts +2 -2
  8. package/lib/builders/assert.js +2 -3
  9. package/lib/configs/poku.d.ts +5 -3
  10. package/lib/configs/poku.js +2 -2
  11. package/lib/modules/essentials/assert.d.ts +1 -1
  12. package/lib/modules/essentials/assert.js +1 -1
  13. package/lib/modules/essentials/poku.js +2 -2
  14. package/lib/modules/essentials/strict.d.ts +5 -4
  15. package/lib/modules/essentials/strict.js +5 -7
  16. package/lib/modules/helpers/create-service.js +4 -4
  17. package/lib/modules/helpers/describe.d.ts +1 -1
  18. package/lib/modules/helpers/describe.js +47 -31
  19. package/lib/modules/helpers/env.js +2 -2
  20. package/lib/modules/helpers/exit.js +2 -2
  21. package/lib/modules/helpers/it/core.d.ts +3 -4
  22. package/lib/modules/helpers/it/core.js +48 -23
  23. package/lib/modules/helpers/list-files.js +6 -3
  24. package/lib/modules/helpers/modifiers.js +1 -1
  25. package/lib/modules/helpers/shared-resources.d.ts +23 -0
  26. package/lib/modules/helpers/shared-resources.js +232 -0
  27. package/lib/modules/helpers/skip.js +1 -1
  28. package/lib/modules/helpers/wait-for.js +2 -2
  29. package/lib/modules/index.d.ts +1 -2
  30. package/lib/modules/index.js +5 -3
  31. package/lib/parsers/assert.js +2 -18
  32. package/lib/parsers/get-arg.js +1 -1
  33. package/lib/parsers/get-runner.js +2 -2
  34. package/lib/parsers/get-runtime.js +2 -2
  35. package/lib/parsers/options.js +36 -3
  36. package/lib/parsers/os.js +1 -1
  37. package/lib/parsers/output.d.ts +1 -0
  38. package/lib/parsers/output.js +19 -1
  39. package/lib/parsers/runtime-version.js +1 -1
  40. package/lib/polyfills/os.js +1 -1
  41. package/lib/services/assert.js +2 -2
  42. package/lib/services/enforce.js +2 -2
  43. package/lib/services/map-tests.js +2 -2
  44. package/lib/services/pid.js +1 -1
  45. package/lib/services/reporters/dot.js +1 -1
  46. package/lib/services/reporters/poku.js +8 -8
  47. package/lib/services/run-test-file.d.ts +2 -1
  48. package/lib/services/run-test-file.js +14 -7
  49. package/lib/services/run-tests.js +25 -7
  50. package/lib/services/shared-resource-loader.d.ts +14 -0
  51. package/lib/services/shared-resource-loader.js +84 -0
  52. package/lib/services/watch.js +3 -3
  53. package/lib/services/write.js +1 -1
  54. package/package.json +14 -13
  55. package/lib/@types/container.d.ts +0 -120
  56. package/lib/modules/helpers/container.d.ts +0 -6
  57. package/lib/modules/helpers/container.js +0 -9
  58. package/lib/services/container.d.ts +0 -32
  59. package/lib/services/container.js +0 -99
package/README.md CHANGED
@@ -18,13 +18,6 @@ Enjoying **Poku**? Give him a star to show your support 🌟
18
18
 
19
19
  </div>
20
20
 
21
- > [!IMPORTANT]
22
- >
23
- > **Poku `v3`** is here! 🎉
24
- >
25
- > - To check out what's changed, follow the [**Issue #801**](https://github.com/wellwelwel/poku/issues/801).
26
- > - For `v2` documentation, see the [**previous version's documentation**](https://poku.io/docs/2.x.x) and [**README**](https://github.com/wellwelwel/poku/tree/2.x.x?tab=readme-ov-file#readme).<br />
27
-
28
21
  ---
29
22
 
30
23
  ## Why does Poku exist?
@@ -245,12 +238,15 @@ To see the detailed documentation, please visit the [**Documentation**](https://
245
238
 
246
239
  ---
247
240
 
248
- ### Common Issues
241
+ ### Common Issues (FAQ)
249
242
 
250
243
  - [Avoiding conflicts in environments with multiple platforms installed](https://poku.io/docs/tutorials/cross-platform#recommendations).
251
244
  - [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises).
252
- - [Using **Poku** without installing on **Deno** and alternatives to **JSR**](https://github.com/wellwelwel/poku/discussions/565).
253
- - [Migrating from version **2.x** to version **3.x**](https://github.com/wellwelwel/poku/issues/801).
245
+ - [Using **Poku** without installing it on **Deno**](https://github.com/wellwelwel/poku/discussions/565).
246
+ - Migrating:
247
+ - [From version **3.x.x** to version **4.x.x (Canary)**](https://github.com/wellwelwel/poku/issues/1006).
248
+ - [From version **2.x.x** to version **3.x.x**](https://github.com/wellwelwel/poku/issues/801).
249
+ - [From version **1.x.x** to version **2.x.x**](https://github.com/wellwelwel/poku/issues/533).
254
250
 
255
251
  ---
256
252
 
@@ -260,9 +256,9 @@ To see the detailed documentation, please visit the [**Documentation**](https://
260
256
 
261
257
  **Poku** is [continuously tested](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml) to ensure the following expectations for basic usage:
262
258
 
263
- - ~**4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0)
264
- - ~**4x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v3.0.6)
265
- - ~**1x** faster than [**Mocha**](https://github.com/mochajs/mocha) (v11.1.0) — _even with test file isolation_
259
+ - ~**3.7x** faster than [**Jest**](https://github.com/jestjs/jest) (v30.2.0)
260
+ - ~**3.2x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v4.0.8)
261
+ - ~**1.1x** _faster_ than [**Mocha**](https://github.com/mochajs/mocha) (v11.7.5) — _even with test file isolation_ 🚀
266
262
 
267
263
  > - You can see how the tests are run and compared in the [benchmark](https://github.com/wellwelwel/poku/tree/main/benchmark) directory.
268
264
  > - [Comparing **Poku** and native test runners _(discussion)_](https://github.com/wellwelwel/poku/discussions/740).
@@ -273,9 +269,9 @@ To see the detailed documentation, please visit the [**Documentation**](https://
273
269
 
274
270
  [![Install Size](https://packagephobia.com/badge?p=poku)](https://pkg-size.dev/poku)
275
271
 
276
- - [~**230x** lighter than **Vitest**](https://pkg-size.dev/vitest)
277
- - [~**130x** lighter than **Jest**](https://pkg-size.dev/jest)
278
- - [~**30x** lighter than **Mocha** + **Chai**](https://pkg-size.dev/mocha%20chai)
272
+ - [~**206x** lighter than **Vitest**](https://pkg-size.dev/vitest@3.2.4)
273
+ - [~**165x** lighter than **Jest**](https://pkg-size.dev/jest@30.0.5)
274
+ - [~**52x** lighter than **Mocha**](https://pkg-size.dev/mocha@11.7.1)
279
275
 
280
276
  > **Poku** size ensures _cost-saving_ **CI** for services that charge for storage and usage.
281
277
 
@@ -297,10 +293,20 @@ See the [**Contributing Guide**](https://github.com/wellwelwel/poku/blob/main/CO
297
293
 
298
294
  ## Acknowledgements
299
295
 
300
- [![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku?color=9c88ff)](https://github.com/wellwelwel/poku/graphs/contributors)
296
+ ### Contributors
297
+
298
+ My thanks to everyone who has dedicated their time and effort to improving **Poku**.
301
299
 
302
300
  [![Contributors](https://opencollective.com/poku/contributors.svg?width=890&button=false)](https://opencollective.com/poku/contributors.svg?button=false)
303
301
 
302
+ ### Sponsors
303
+
304
+ Really thanks to everyone who has supported and keeps supporting my work.
305
+
306
+ > _Also for the private ones, who don't appear here_ 🕵
307
+
308
+ [![Sponsors](https://wellwelwel.github.io/wellwelwel/sponsors.svg?v=1)](https://github.com/sponsors/wellwelwel)
309
+
304
310
  ---
305
311
 
306
312
  ## License
@@ -1,4 +1,4 @@
1
- import type { AssertionError } from "assert";
1
+ import type { AssertionError } from 'node:assert';
2
2
  import type { results } from '../configs/poku.js';
3
3
  import type { ProcessAssertionOptions } from './assert.js';
4
4
  import type { DescribeOptions } from './describe.js';
@@ -54,6 +54,12 @@ export type Configs = {
54
54
  * @default "poku"
55
55
  */
56
56
  reporter?: Reporter;
57
+ /**
58
+ * By default, **Poku** runs in full isolation mode. Sharing resources allows IPC-based sharing of resources between test files.
59
+ *
60
+ * @default false
61
+ */
62
+ sharedResources?: boolean;
57
63
  /**
58
64
  * You can use this option to run a **callback** or a **file** before each test file on your suite.
59
65
  *
@@ -124,20 +130,22 @@ type Path = {
124
130
  };
125
131
  export type ReporterPlugin = (configs?: Configs) => {
126
132
  onRunStart: () => void;
127
- onDescribeAsTitle: (title: string, options: DescribeOptions) => void;
133
+ onDescribeAsTitle: (title: string, options?: DescribeOptions) => void;
128
134
  onDescribeStart: (options: {
129
135
  title?: string;
130
136
  }) => void;
131
137
  onDescribeEnd: (options: {
132
- title?: string;
133
138
  duration: number;
139
+ success?: boolean;
140
+ title?: string;
134
141
  }) => void;
135
142
  onItStart: (options: {
136
143
  title?: string;
137
144
  }) => void;
138
145
  onItEnd: (options: {
139
- title?: string;
140
146
  duration: number;
147
+ success?: boolean;
148
+ title?: string;
141
149
  }) => void;
142
150
  onAssertionSuccess: (options: {
143
151
  message: string;
@@ -0,0 +1,65 @@
1
+ import type { Serializable } from 'node:child_process';
2
+ import type EventEmitter from 'node:events';
3
+ import type { SHARED_RESOURCE_MESSAGE_TYPES } from '../modules/helpers/shared-resources.js';
4
+ export interface IPCEventEmitter extends EventEmitter {
5
+ send: (message: unknown, ...args: unknown[]) => boolean;
6
+ }
7
+ export interface SharedResourceEntry<T = unknown> {
8
+ state: T;
9
+ subscribers: Set<(state: T) => void>;
10
+ }
11
+ export type SharedResource = Record<string, unknown>;
12
+ export type IPCGetMessage = {
13
+ type: typeof SHARED_RESOURCE_MESSAGE_TYPES.GET_RESOURCE;
14
+ name: string;
15
+ id: string;
16
+ };
17
+ export type IPCRemoteProcedureCallMessage = {
18
+ type: typeof SHARED_RESOURCE_MESSAGE_TYPES.REMOTE_PROCEDURE_CALL;
19
+ name: string;
20
+ id: string;
21
+ method: string | number | symbol;
22
+ args: unknown[];
23
+ };
24
+ export type IPCMessage = IPCGetMessage | IPCRemoteProcedureCallMessage;
25
+ export type IPCResourceNotFoundMessage = {
26
+ type: typeof SHARED_RESOURCE_MESSAGE_TYPES.RESOURCE_NOT_FOUND;
27
+ name: string;
28
+ };
29
+ export type IPCResourceResultMessage<T = unknown> = {
30
+ type: typeof SHARED_RESOURCE_MESSAGE_TYPES.RESOURCE_RESULT;
31
+ name: string;
32
+ id: string;
33
+ value: T;
34
+ rpcs: MethodsOf<T>[];
35
+ };
36
+ export type IPCListenable<T> = IPCResourceResultMessage<T> | IPCResourceUpdatedMessage<T>;
37
+ export type IPCResourceUpdatedMessage<T = unknown> = {
38
+ type: typeof SHARED_RESOURCE_MESSAGE_TYPES.RESOURCE_UPDATED;
39
+ name: string;
40
+ value: T;
41
+ rpcs: MethodsOf<T>[];
42
+ };
43
+ export type IPCRemoteProcedureCallResultMessage<T = unknown> = {
44
+ type: typeof SHARED_RESOURCE_MESSAGE_TYPES.REMOTE_PROCEDURE_CALL_RESULT;
45
+ id: string;
46
+ value?: T;
47
+ error?: string;
48
+ };
49
+ export type IPCResponse = IPCResourceResultMessage | IPCResourceUpdatedMessage | IPCRemoteProcedureCallResultMessage;
50
+ export type RPCResult<TResult, TResource> = {
51
+ result: TResult;
52
+ latest: TResource;
53
+ };
54
+ export type MethodsToRPC<T> = {
55
+ [K in keyof T]: T[K] extends (...args: infer _) => Serializable ? (...args: Parameters<T[K]>) => ReturnType<T[K]> extends Promise<unknown> ? ReturnType<T[K]> : Promise<ReturnType<T[K]>> : T[K];
56
+ };
57
+ export type MethodsOf<T> = {
58
+ [K in keyof T]: T[K] extends (...args: infer _) => Serializable ? K : never;
59
+ }[keyof T];
60
+ export type ArgumentsOf<T> = T extends MethodsOf<infer U> ? U extends (...args: infer P) => Serializable ? P & {
61
+ length: number;
62
+ } : never : never;
63
+ export type ReturnTypeOf<T> = T extends MethodsOf<infer U> ? U extends (...args: infer _) => infer R ? R : never : never;
64
+ export type Cleanup<T = SharedResourceEntry> = (state: T) => void | Promise<void>;
65
+ export type Registry = Record<string, SharedResourceEntry>;
package/lib/bin/help.js CHANGED
@@ -33,6 +33,7 @@ const summary = [
33
33
  ],
34
34
  ['--only', 'Enable selective execution of tests.'],
35
35
  ['--quiet, -q', 'Run tests with no logs.'],
36
+ ['--sharedResources', 'Share state and methods between isolated test files.'],
36
37
  ['--sequential', 'Run tests files sequentially.'],
37
38
  ['--version, -v', "Show Poku's installed version."],
38
39
  ['--watch, -w', 'Watch for test events.'],
package/lib/bin/index.js CHANGED
@@ -1,5 +1,38 @@
1
1
  #! /usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  Object.defineProperty(exports, "__esModule", { value: true });
4
37
  const poku_js_1 = require("../configs/poku.js");
5
38
  const poku_js_2 = require("../modules/essentials/poku.js");
@@ -17,7 +50,7 @@ const write_js_1 = require("../services/write.js");
17
50
  return;
18
51
  }
19
52
  if ((0, get_arg_js_1.hasArg)('help') || (0, get_arg_js_1.hasArg)('h', '-')) {
20
- require('./help.js').help();
53
+ (await Promise.resolve().then(() => __importStar(require('./help.js')))).help();
21
54
  return;
22
55
  }
23
56
  const enforce = (0, get_arg_js_1.hasArg)('enforce') || (0, get_arg_js_1.hasArg)('x', '-');
@@ -57,10 +90,11 @@ const write_js_1 = require("../services/write.js");
57
90
  return Number.isNaN(value) ? configsFromFile?.concurrency : value;
58
91
  })();
59
92
  const sequential = (0, get_arg_js_1.hasArg)('sequential');
93
+ const sharedResources = (0, get_arg_js_1.hasArg)('sharedResources') || configsFromFile?.sharedResources;
60
94
  if (dirs.length === 1)
61
95
  poku_js_1.states.isSinglePath = true;
62
96
  if ((0, get_arg_js_1.hasArg)('listFiles')) {
63
- const { listFiles } = require('../modules/helpers/list-files.js');
97
+ const { listFiles } = await Promise.resolve().then(() => __importStar(require('../modules/helpers/list-files.js')));
64
98
  const files = [];
65
99
  (0, write_js_1.hr)();
66
100
  for (const dir of dirs)
@@ -95,6 +129,7 @@ const write_js_1 = require("../services/write.js");
95
129
  deny: denoDeny,
96
130
  cjs: denoCJS,
97
131
  },
132
+ sharedResources,
98
133
  noExit: watchMode,
99
134
  reporter,
100
135
  beforeEach: 'beforeEach' in configsFromFile ? configsFromFile.beforeEach : undefined,
@@ -105,8 +140,7 @@ const write_js_1 = require("../services/write.js");
105
140
  poku_js_1.GLOBAL.envFile = (0, get_arg_js_1.getArg)('envFile') ?? configsFromFile?.envFile ?? '.env';
106
141
  }
107
142
  if (enforce)
108
- require('../services/enforce.js').enforce();
109
-
143
+ (await Promise.resolve().then(() => __importStar(require('../services/enforce.js')))).enforce();
110
144
  if (killPort || configsFromFile?.kill?.port) {
111
145
  const ports = killPort?.split(',').map(Number) || configsFromFile?.kill?.port || [];
112
146
  tasks.push(kill_js_1.kill.port(ports));
@@ -126,7 +160,6 @@ const write_js_1 = require("../services/write.js");
126
160
  const PIDs = killPID?.split(',').map(Number) || configsFromFile?.kill?.pid || [];
127
161
  tasks.push(kill_js_1.kill.pid(PIDs));
128
162
  }
129
-
130
163
  poku_js_1.GLOBAL.envFile && tasks.push((0, env_js_1.envFile)(poku_js_1.GLOBAL.envFile));
131
164
  if (debug || configsFromFile?.debug) {
132
165
  (0, write_js_1.hr)();
@@ -140,7 +173,6 @@ const write_js_1 = require("../services/write.js");
140
173
  }
141
174
  await Promise.all(tasks);
142
175
  await (0, poku_js_2.poku)(dirs);
143
-
144
176
  if (watchMode)
145
- await require('./watch.js').startWatch(dirs);
177
+ require('./watch.js').startWatch(dirs);
146
178
  })();
package/lib/bin/watch.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.startWatch = void 0;
7
- const node_process_1 = __importDefault(require("process"));
7
+ const node_process_1 = __importDefault(require("node:process"));
8
8
  const poku_js_1 = require("../configs/poku.js");
9
9
  const poku_js_2 = require("../modules/essentials/poku.js");
10
10
  const get_arg_js_1 = require("../parsers/get-arg.js");
@@ -1,5 +1,5 @@
1
- import type assert from "assert";
2
- import type { AssertPredicate } from "assert";
1
+ import type assert from 'node:assert';
2
+ import type { AssertPredicate } from 'node:assert';
3
3
  import type { ProcessAssertionOptions } from '../@types/assert.js';
4
4
  export declare const createAssert: (nodeAssert: typeof assert) => ((value: unknown, message?: ProcessAssertionOptions["message"]) => void) & {
5
5
  ok: (value: unknown, message?: ProcessAssertionOptions["message"]) => void;
@@ -78,8 +78,7 @@ const createAssert = (nodeAssert) => {
78
78
  typeof errorOrMessage === 'object')
79
79
  await nodeAssert.rejects(block, errorOrMessage, message);
80
80
  else {
81
- const msg = typeof errorOrMessage === 'string' ? errorOrMessage : message;
82
- await nodeAssert.rejects(block, msg);
81
+ await nodeAssert.rejects(block);
83
82
  }
84
83
  }, {
85
84
  message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
@@ -95,7 +94,7 @@ const createAssert = (nodeAssert) => {
95
94
  typeof errorOrMessage === 'object')
96
95
  await nodeAssert.doesNotReject(block, errorOrMessage, message);
97
96
  else
98
- await nodeAssert.doesNotReject(block, message);
97
+ await nodeAssert.doesNotReject(block);
99
98
  }, {
100
99
  message: typeof errorOrMessage === 'string' ? errorOrMessage : message,
101
100
  defaultMessage: 'Got unwanted rejection',
@@ -16,20 +16,22 @@ export declare const GLOBAL: {
16
16
  configsFromFile: ConfigFile | ConfigJSONFile;
17
17
  reporter: {
18
18
  onRunStart: () => void;
19
- onDescribeAsTitle: (title: string, options: import("../@types/describe.js").DescribeOptions) => void;
19
+ onDescribeAsTitle: (title: string, options?: import("../@types/describe.js").DescribeOptions) => void;
20
20
  onDescribeStart: (options: {
21
21
  title?: string;
22
22
  }) => void;
23
23
  onDescribeEnd: (options: {
24
- title?: string;
25
24
  duration: number;
25
+ success?: boolean;
26
+ title?: string;
26
27
  }) => void;
27
28
  onItStart: (options: {
28
29
  title?: string;
29
30
  }) => void;
30
31
  onItEnd: (options: {
31
- title?: string;
32
32
  duration: number;
33
+ success?: boolean;
34
+ title?: string;
33
35
  }) => void;
34
36
  onAssertionSuccess: (options: {
35
37
  message: string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GLOBAL = exports.deepOptions = exports.VERSION = exports.results = exports.timespan = exports.states = void 0;
4
- const node_process_1 = require("process");
4
+ const node_process_1 = require("node:process");
5
5
  const get_runtime_js_1 = require("../parsers/get-runtime.js");
6
6
  const reporter_js_1 = require("../services/reporter.js");
7
7
  exports.states = Object.create(null);
@@ -12,7 +12,7 @@ exports.results = {
12
12
  skipped: 0,
13
13
  todo: 0,
14
14
  };
15
- exports.VERSION = '3.0.2';
15
+ exports.VERSION = '3.0.3-canary.24dfb51d';
16
16
  exports.deepOptions = [];
17
17
  exports.GLOBAL = {
18
18
  cwd: (0, node_process_1.cwd)(),
@@ -1,4 +1,4 @@
1
- import nodeAssert from "assert";
1
+ import nodeAssert from 'node:assert';
2
2
  export declare const assert: ((value: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void) & {
3
3
  ok: (value: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
4
4
  equal: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
@@ -4,6 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.assert = void 0;
7
- const node_assert_1 = __importDefault(require("assert"));
7
+ const node_assert_1 = __importDefault(require("node:assert"));
8
8
  const assert_js_1 = require("../../builders/assert.js");
9
9
  exports.assert = (0, assert_js_1.createAssert)(node_assert_1.default);
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.onSigint = void 0;
7
7
  exports.poku = poku;
8
- const node_path_1 = require("path");
9
- const node_process_1 = __importDefault(require("process"));
8
+ const node_path_1 = require("node:path");
9
+ const node_process_1 = __importDefault(require("node:process"));
10
10
  const poku_js_1 = require("../../configs/poku.js");
11
11
  const reporter_js_1 = require("../../services/reporter.js");
12
12
  const run_tests_js_1 = require("../../services/run-tests.js");
@@ -1,3 +1,4 @@
1
+ import nodeAssert from 'node:assert/strict';
1
2
  export declare const strict: ((value: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void) & {
2
3
  ok: (value: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
3
4
  equal: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
@@ -7,15 +8,15 @@ export declare const strict: ((value: unknown, message?: import("../../@types/as
7
8
  doesNotMatch: (value: string, regExp: RegExp, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
8
9
  doesNotReject: {
9
10
  (block: (() => Promise<unknown>) | Promise<unknown>, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
10
- (block: (() => Promise<unknown>) | Promise<unknown>, error: import("assert").AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
11
+ (block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
11
12
  };
12
13
  throws: {
13
14
  (block: () => unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
14
- (block: () => unknown, error: import("assert").AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
15
+ (block: () => unknown, error: nodeAssert.AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
15
16
  };
16
17
  doesNotThrow: {
17
18
  (block: () => unknown, message?: string | import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
18
- (block: () => unknown, error: import("assert").AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
19
+ (block: () => unknown, error: nodeAssert.AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): void;
19
20
  };
20
21
  notEqual: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
21
22
  notDeepEqual: (actual: unknown, expected: unknown, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => void;
@@ -26,6 +27,6 @@ export declare const strict: ((value: unknown, message?: import("../../@types/as
26
27
  fail: (message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]) => never;
27
28
  rejects: {
28
29
  (block: (() => Promise<unknown>) | Promise<unknown>, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
29
- (block: (() => Promise<unknown>) | Promise<unknown>, error: import("assert").AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
30
+ (block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: import("../../@types/assert.js").ProcessAssertionOptions["message"]): Promise<void>;
30
31
  };
31
32
  };
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.strict = void 0;
7
+ const strict_1 = __importDefault(require("node:assert/strict"));
4
8
  const assert_js_1 = require("../../builders/assert.js");
5
- const poku_js_1 = require("../../configs/poku.js");
6
- const runtime_version_js_1 = require("../../parsers/runtime-version.js");
7
-
8
- const nodeAssert = poku_js_1.GLOBAL.runtime !== 'node' || runtime_version_js_1.runtimeVersion >= 16
9
- ? require("assert/strict")
10
- : require("assert");
11
- exports.strict = (0, assert_js_1.createAssert)(nodeAssert);
9
+ exports.strict = (0, assert_js_1.createAssert)(strict_1.default);
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.startScript = exports.startService = void 0;
7
- const node_child_process_1 = require("child_process");
8
- const node_path_1 = require("path");
9
- const node_process_1 = __importDefault(require("process"));
7
+ const node_child_process_1 = require("node:child_process");
8
+ const node_path_1 = require("node:path");
9
+ const node_process_1 = __importDefault(require("node:process"));
10
10
  const get_runner_js_1 = require("../../parsers/get-runner.js");
11
11
  const os_js_1 = require("../../parsers/os.js");
12
12
  const write_js_1 = require("../../services/write.js");
@@ -21,7 +21,7 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
21
21
  env: node_process_1.default.env,
22
22
  timeout: options?.timeout,
23
23
  cwd: options?.cwd ? (0, list_files_js_1.sanitizePath)((0, node_path_1.normalize)(options.cwd)) : undefined,
24
- shell: os_js_1.isWindows,
24
+ shell: false,
25
25
  detached: !os_js_1.isWindows,
26
26
  windowsHide: os_js_1.isWindows,
27
27
  });
@@ -1,6 +1,6 @@
1
1
  import type { DescribeOptions } from '../../@types/describe.js';
2
2
  import { onlyDescribe, skip, todo } from './modifiers.js';
3
- export declare function describeBase(arg1: string | (() => unknown | Promise<unknown>), arg2?: (() => unknown | Promise<unknown>) | DescribeOptions): Promise<void>;
3
+ export declare const describeBase: (titleOrCb: string | (() => unknown | Promise<unknown>), callbackOrOptions?: (() => unknown | Promise<unknown>) | DescribeOptions) => Promise<void>;
4
4
  declare function describeCore(message: string, cb: () => Promise<unknown>): Promise<void>;
5
5
  declare function describeCore(message: string, cb: () => unknown): void;
6
6
  declare function describeCore(cb: () => Promise<unknown>): Promise<void>;
@@ -1,30 +1,28 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.describe = void 0;
4
- exports.describeBase = describeBase;
5
- const node_process_1 = require("process");
6
+ exports.describe = exports.describeBase = void 0;
7
+ const node_assert_1 = require("node:assert");
8
+ const node_process_1 = __importDefault(require("node:process"));
6
9
  const poku_js_1 = require("../../configs/poku.js");
7
10
  const callback_js_1 = require("../../parsers/callback.js");
8
11
  const get_arg_js_1 = require("../../parsers/get-arg.js");
12
+ const core_js_1 = require("./it/core.js");
9
13
  const modifiers_js_1 = require("./modifiers.js");
10
- async function describeBase(arg1, arg2) {
11
- let title;
12
- let cb;
13
- let options;
14
+ const getOptions = (input) => !input || typeof input !== 'object' ? undefined : input;
15
+ const describeBase = async (titleOrCb, callbackOrOptions) => {
14
16
  const { reporter } = poku_js_1.GLOBAL;
15
- if (typeof arg1 === 'string') {
16
- title = arg1;
17
- if (typeof arg2 === 'function')
18
- cb = arg2;
19
- else
20
- options = arg2;
21
- }
22
- else if (typeof arg1 === 'function') {
23
- cb = arg1;
24
- options = arg2;
25
- }
17
+ const title = (0, core_js_1.getTitle)(titleOrCb);
18
+ const hasTitle = typeof title === 'string';
19
+ const cb = hasTitle ? (0, core_js_1.getCallback)(callbackOrOptions) : (0, core_js_1.getCallback)(titleOrCb);
26
20
  const hasCB = typeof cb === 'function';
27
- if (title) {
21
+ const options = hasCB ? undefined : getOptions(callbackOrOptions);
22
+ let success = true;
23
+ let start;
24
+ let end;
25
+ if (hasTitle) {
28
26
  if (hasCB)
29
27
  reporter.onDescribeStart({ title });
30
28
  else
@@ -32,33 +30,51 @@ async function describeBase(arg1, arg2) {
32
30
  }
33
31
  if (!hasCB)
34
32
  return;
35
- const start = (0, node_process_1.hrtime)();
36
- const resultCb = cb();
37
- if (resultCb instanceof Promise)
38
- await resultCb;
39
- const end = (0, node_process_1.hrtime)(start);
33
+ const onError = (error) => {
34
+ node_process_1.default.exitCode = 1;
35
+ success = false;
36
+ if (!(error instanceof node_assert_1.AssertionError))
37
+ console.error(error);
38
+ };
39
+ node_process_1.default.once('uncaughtException', onError);
40
+ node_process_1.default.once('unhandledRejection', onError);
41
+ start = node_process_1.default.hrtime();
42
+ try {
43
+ const resultCb = cb();
44
+ if (resultCb instanceof Promise)
45
+ await resultCb;
46
+ }
47
+ catch (error) {
48
+ onError(error);
49
+ }
50
+ finally {
51
+ end = node_process_1.default.hrtime(start);
52
+ node_process_1.default.removeListener('uncaughtException', onError);
53
+ node_process_1.default.removeListener('unhandledRejection', onError);
54
+ }
40
55
  if (!title)
41
56
  return;
42
57
  const duration = end[0] * 1e3 + end[1] / 1e6;
43
- reporter.onDescribeEnd({ title, duration });
58
+ reporter.onDescribeEnd({ title, duration, success });
44
59
  poku_js_1.GLOBAL.runAsOnly = false;
45
- }
60
+ };
61
+ exports.describeBase = describeBase;
46
62
  async function describeCore(messageOrCb, cbOrOptions) {
47
63
  if (typeof messageOrCb === 'string' && typeof cbOrOptions !== 'function')
48
- return describeBase(messageOrCb, cbOrOptions);
64
+ return (0, exports.describeBase)(messageOrCb, cbOrOptions);
49
65
  if (get_arg_js_1.hasOnly) {
50
66
  const hasItOnly = (0, callback_js_1.checkOnly)(typeof messageOrCb === 'function' ? messageOrCb : cbOrOptions);
51
67
  if (!hasItOnly)
52
68
  return;
53
69
  if (typeof messageOrCb === 'string' && typeof cbOrOptions === 'function')
54
- return describeBase(messageOrCb, cbOrOptions);
70
+ return (0, exports.describeBase)(messageOrCb, cbOrOptions);
55
71
  if (typeof messageOrCb === 'function')
56
- return describeBase(messageOrCb);
72
+ return (0, exports.describeBase)(messageOrCb);
57
73
  }
58
74
  if (typeof messageOrCb === 'string' && typeof cbOrOptions === 'function')
59
- return describeBase(messageOrCb, cbOrOptions);
75
+ return (0, exports.describeBase)(messageOrCb, cbOrOptions);
60
76
  if (typeof messageOrCb === 'function')
61
- return describeBase(messageOrCb);
77
+ return (0, exports.describeBase)(messageOrCb);
62
78
  }
63
79
  exports.describe = Object.assign(describeCore, {
64
80
  todo: modifiers_js_1.todo,
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.envFile = void 0;
4
- const promises_1 = require("fs/promises");
5
- const node_process_1 = require("process");
4
+ const promises_1 = require("node:fs/promises");
5
+ const node_process_1 = require("node:process");
6
6
  const env_js_1 = require("../../services/env.js");
7
7
  const list_files_js_1 = require("./list-files.js");
8
8
  const regex = {
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.exit = void 0;
7
- const node_assert_1 = require("assert");
8
- const node_process_1 = __importDefault(require("process"));
7
+ const node_assert_1 = require("node:assert");
8
+ const node_process_1 = __importDefault(require("node:process"));
9
9
  const poku_js_1 = require("../../configs/poku.js");
10
10
  const exit = (code, quiet) => {
11
11
  const isPoku = poku_js_1.results.passed > 0 || poku_js_1.results.failed > 0;
@@ -1,8 +1,7 @@
1
1
  import { onlyIt, skip, todo } from '../modifiers.js';
2
- export declare function itBase(...args: [
3
- string | (() => unknown | Promise<unknown>),
4
- (() => unknown | Promise<unknown>)?
5
- ]): Promise<void>;
2
+ export declare const getTitle: (input: unknown) => string | undefined;
3
+ export declare const getCallback: (input: unknown) => (() => unknown) | (() => Promise<unknown>) | undefined;
4
+ export declare const itBase: (titleOrCb: string | (() => unknown | Promise<unknown>), callback?: () => unknown | Promise<unknown>) => Promise<void>;
6
5
  declare function itCore(title: string, cb: () => Promise<unknown>): Promise<void>;
7
6
  declare function itCore(title: string, cb: () => unknown): void;
8
7
  declare function itCore(cb: () => Promise<unknown>): Promise<void>;