poku 4.3.1 → 4.3.2-canary.592a1ca5

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 (87) hide show
  1. package/README.md +10 -2
  2. package/lib/builders/assert.js +9 -10
  3. package/lib/configs/poku.js +1 -1
  4. package/lib/modules/_shared.d.ts +217 -0
  5. package/lib/modules/essentials/poku.js +3 -4
  6. package/lib/modules/helpers/create-service.js +0 -9
  7. package/lib/modules/helpers/describe.js +6 -6
  8. package/lib/modules/helpers/each.js +0 -34
  9. package/lib/modules/helpers/env.js +0 -1
  10. package/lib/modules/helpers/get-pids.js +0 -2
  11. package/lib/modules/helpers/it/core.js +7 -10
  12. package/lib/modules/helpers/kill.js +0 -4
  13. package/lib/modules/helpers/log.js +0 -1
  14. package/lib/modules/helpers/modifiers.js +15 -18
  15. package/lib/modules/helpers/wait-for.js +0 -3
  16. package/lib/modules/index.d.ts +153 -25
  17. package/lib/modules/index.js +0 -1
  18. package/lib/modules/plugins.d.ts +17 -11
  19. package/lib/modules/plugins.js +0 -2
  20. package/lib/parsers/find-file-from-stack.js +0 -3
  21. package/lib/parsers/get-runner.js +0 -1
  22. package/lib/parsers/get-test-args.js +7 -0
  23. package/lib/polyfills/jsonc.js +0 -3
  24. package/package.json +19 -9
  25. package/lib/@types/assert.d.ts +0 -8
  26. package/lib/@types/background-process.d.ts +0 -41
  27. package/lib/@types/code.d.ts +0 -1
  28. package/lib/@types/describe.d.ts +0 -8
  29. package/lib/@types/each.d.ts +0 -12
  30. package/lib/@types/list-files.d.ts +0 -14
  31. package/lib/@types/plugin.d.ts +0 -106
  32. package/lib/@types/poku.d.ts +0 -148
  33. package/lib/@types/runner.d.ts +0 -1
  34. package/lib/@types/wait-for.d.ts +0 -46
  35. package/lib/@types/watch.d.ts +0 -1
  36. package/lib/builders/assert.d.ts +0 -34
  37. package/lib/builders/reporter.d.ts +0 -2
  38. package/lib/configs/each.d.ts +0 -5
  39. package/lib/configs/indentation.d.ts +0 -6
  40. package/lib/configs/poku.d.ts +0 -85
  41. package/lib/modules/essentials/assert.d.ts +0 -32
  42. package/lib/modules/essentials/poku.d.ts +0 -7
  43. package/lib/modules/essentials/strict.d.ts +0 -32
  44. package/lib/modules/helpers/create-service.d.ts +0 -16
  45. package/lib/modules/helpers/describe.d.ts +0 -14
  46. package/lib/modules/helpers/each.d.ts +0 -37
  47. package/lib/modules/helpers/env.d.ts +0 -2
  48. package/lib/modules/helpers/exit.d.ts +0 -2
  49. package/lib/modules/helpers/get-pids.d.ts +0 -5
  50. package/lib/modules/helpers/it/core.d.ts +0 -15
  51. package/lib/modules/helpers/kill.d.ts +0 -9
  52. package/lib/modules/helpers/list-files.d.ts +0 -6
  53. package/lib/modules/helpers/log.d.ts +0 -2
  54. package/lib/modules/helpers/modifiers.d.ts +0 -15
  55. package/lib/modules/helpers/skip.d.ts +0 -1
  56. package/lib/modules/helpers/test.d.ts +0 -10
  57. package/lib/modules/helpers/wait-for.d.ts +0 -7
  58. package/lib/parsers/assert.d.ts +0 -1
  59. package/lib/parsers/callback.d.ts +0 -2
  60. package/lib/parsers/find-file-from-stack.d.ts +0 -3
  61. package/lib/parsers/get-arg.d.ts +0 -5
  62. package/lib/parsers/get-runner.d.ts +0 -3
  63. package/lib/parsers/get-runtime.d.ts +0 -2
  64. package/lib/parsers/options.d.ts +0 -2
  65. package/lib/parsers/os.d.ts +0 -1
  66. package/lib/parsers/output.d.ts +0 -5
  67. package/lib/parsers/time.d.ts +0 -2
  68. package/lib/polyfills/jsonc.d.ts +0 -6
  69. package/lib/polyfills/os.d.ts +0 -1
  70. package/lib/services/assert.d.ts +0 -2
  71. package/lib/services/each.d.ts +0 -2
  72. package/lib/services/enforce.d.ts +0 -1
  73. package/lib/services/env.d.ts +0 -6
  74. package/lib/services/format.d.ts +0 -35
  75. package/lib/services/map-tests.d.ts +0 -6
  76. package/lib/services/pid.d.ts +0 -10
  77. package/lib/services/reporter.d.ts +0 -2
  78. package/lib/services/reporters/classic.d.ts +0 -2
  79. package/lib/services/reporters/compact.d.ts +0 -2
  80. package/lib/services/reporters/dot.d.ts +0 -2
  81. package/lib/services/reporters/focus.d.ts +0 -2
  82. package/lib/services/reporters/poku.d.ts +0 -6
  83. package/lib/services/run-test-file.d.ts +0 -1
  84. package/lib/services/run-test-in-process.d.ts +0 -1
  85. package/lib/services/run-tests.d.ts +0 -1
  86. package/lib/services/watch.d.ts +0 -17
  87. package/lib/services/write.d.ts +0 -3
package/README.md CHANGED
@@ -260,8 +260,8 @@ To see the detailed documentation, please visit the [**Documentation**](https://
260
260
 
261
261
  **Poku** is [continuously tested](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml) to ensure the following average expectations for basic usage:
262
262
 
263
- - ~**4.6x** faster than [**Jest**](https://github.com/jestjs/jest) (v30.3.0)
264
- - ~**3.5x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v4.1.2)
263
+ - ~**4.6x** faster than [**Jest**](https://github.com/jestjs/jest) (v30.4.2)
264
+ - ~**3.5x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v4.1.6)
265
265
 
266
266
  > - You can see how the tests are run and compared in the [benchmark](https://github.com/wellwelwel/poku/tree/main/benchmark) directory.
267
267
  > - [Comparing **Poku** and native test runners _(discussion)_](https://github.com/wellwelwel/poku/discussions/740).
@@ -312,6 +312,14 @@ Really thanks to everyone who has supported and keeps supporting my work.
312
312
 
313
313
  ---
314
314
 
315
+ ## AI & Open Source
316
+
317
+ 🤖 **LLM**s can help a lot with productivity, but please, use them as a tool, not as an autopilot.
318
+
319
+ [**If you'd like to contribute to the project**](./CONTRIBUTING.md), please keep this in mind: we'd love to read what you, a human, have written 🤝
320
+
321
+ ---
322
+
315
323
  ## License
316
324
 
317
325
  **Poku** is under the [**MIT License**](https://github.com/wellwelwel/poku/blob/main/LICENSE).<br />
@@ -36,7 +36,7 @@ const createAssert = (nodeAssert) => {
36
36
  });
37
37
  process.exit(1);
38
38
  };
39
- function doesNotThrow(block, errorOrMessage, message) {
39
+ const doesNotThrow = ((block, errorOrMessage, message) => {
40
40
  (0, assert_js_1.processAssert)(() => {
41
41
  if (typeof errorOrMessage === 'function' ||
42
42
  errorOrMessage instanceof RegExp ||
@@ -52,8 +52,8 @@ const createAssert = (nodeAssert) => {
52
52
  hideDiff: true,
53
53
  throw: true,
54
54
  });
55
- }
56
- function throws(block, errorOrMessage, message) {
55
+ });
56
+ const throws = ((block, errorOrMessage, message) => {
57
57
  if (typeof errorOrMessage === 'function' ||
58
58
  errorOrMessage instanceof RegExp ||
59
59
  typeof errorOrMessage === 'object')
@@ -70,8 +70,8 @@ const createAssert = (nodeAssert) => {
70
70
  hideDiff: true,
71
71
  });
72
72
  }
73
- }
74
- async function rejects(block, errorOrMessage, message) {
73
+ });
74
+ const rejects = (async (block, errorOrMessage, message) => {
75
75
  await (0, assert_js_1.processAsyncAssert)(async () => {
76
76
  if (typeof errorOrMessage === 'function' ||
77
77
  errorOrMessage instanceof RegExp ||
@@ -87,8 +87,8 @@ const createAssert = (nodeAssert) => {
87
87
  hideDiff: true,
88
88
  throw: true,
89
89
  });
90
- }
91
- async function doesNotReject(block, errorOrMessage, message) {
90
+ });
91
+ const doesNotReject = (async (block, errorOrMessage, message) => {
92
92
  await (0, assert_js_1.processAsyncAssert)(async () => {
93
93
  if (typeof errorOrMessage === 'function' ||
94
94
  errorOrMessage instanceof RegExp ||
@@ -102,7 +102,7 @@ const createAssert = (nodeAssert) => {
102
102
  hideDiff: true,
103
103
  throw: true,
104
104
  });
105
- }
105
+ });
106
106
  const match = (value, regExp, message) => {
107
107
  (0, assert_js_1.processAssert)(() => nodeAssert?.match(value, regExp), {
108
108
  message,
@@ -119,7 +119,7 @@ const createAssert = (nodeAssert) => {
119
119
  defaultMessage: 'Value should not match regExp',
120
120
  });
121
121
  };
122
- const assert = Object.assign((value, message) => ok(value, message), {
122
+ return Object.assign(((value, message) => ok(value, message)), {
123
123
  ok,
124
124
  equal,
125
125
  deepEqual,
@@ -138,6 +138,5 @@ const createAssert = (nodeAssert) => {
138
138
  fail,
139
139
  rejects,
140
140
  });
141
- return assert;
142
141
  };
143
142
  exports.createAssert = createAssert;
@@ -21,7 +21,7 @@ exports.results = {
21
21
  skipped: 0,
22
22
  todo: 0,
23
23
  };
24
- exports.VERSION = '4.3.1';
24
+ exports.VERSION = '4.3.2-canary.592a1ca5';
25
25
  exports.deepOptions = [];
26
26
  exports.GLOBAL = {
27
27
  cwd: (0, node_process_1.cwd)(),
@@ -0,0 +1,217 @@
1
+ import { AssertPredicate, AssertionError } from 'node:assert';
2
+ import { ChildProcess, ChildProcessWithoutNullStreams } from 'node:child_process';
3
+
4
+ type Code = 0 | 1;
5
+
6
+ type Configs$1 = {
7
+ filter?: RegExp;
8
+ exclude?: RegExp | RegExp[];
9
+ };
10
+
11
+ type ProcessAssertionOptions = {
12
+ message?: string | Error;
13
+ defaultMessage?: string;
14
+ actual?: string;
15
+ expected?: string;
16
+ throw?: boolean;
17
+ hideDiff?: boolean;
18
+ };
19
+ type AssertionMessage = ProcessAssertionOptions['message'];
20
+ type AssertValue = (value: unknown, message?: AssertionMessage) => void;
21
+ type AssertEqual = (actual: unknown, expected: unknown, message?: AssertionMessage) => void;
22
+ type AssertMatch = (value: string, regExp: RegExp, message?: AssertionMessage) => void;
23
+ type AsyncBlock = (() => Promise<unknown>) | Promise<unknown>;
24
+ type AssertThrows = {
25
+ (block: () => unknown, message?: AssertionMessage): void;
26
+ (block: () => unknown, error: AssertPredicate, message?: AssertionMessage): void;
27
+ };
28
+ type AssertRejects = {
29
+ (block: AsyncBlock, message?: AssertionMessage): Promise<void>;
30
+ (block: AsyncBlock, error: AssertPredicate, message?: AssertionMessage): Promise<void>;
31
+ };
32
+
33
+ declare const backgroundColor: {
34
+ readonly white: 7;
35
+ readonly black: 40;
36
+ readonly grey: 100;
37
+ readonly red: 41;
38
+ readonly green: 42;
39
+ readonly yellow: 43;
40
+ readonly blue: 44;
41
+ readonly magenta: 45;
42
+ readonly cyan: 46;
43
+ readonly brightRed: 101;
44
+ readonly brightGreen: 102;
45
+ readonly brightYellow: 103;
46
+ readonly brightBlue: 104;
47
+ readonly brightMagenta: 105;
48
+ readonly brightCyan: 106;
49
+ };
50
+
51
+ type DescribeOptions = {
52
+ background?: keyof typeof backgroundColor | boolean;
53
+ icon?: string;
54
+ };
55
+ type Describe = {
56
+ (message: string, cb: AsyncTestCb): Promise<void>;
57
+ (message: string, cb: TestCb): void;
58
+ (cb: AsyncTestCb): Promise<void>;
59
+ (cb: TestCb): void;
60
+ (message: string, options?: DescribeOptions): void;
61
+ };
62
+
63
+ declare const timespan: Timespan;
64
+ declare const results: {
65
+ passed: number;
66
+ failed: number;
67
+ skipped: number;
68
+ todo: number;
69
+ };
70
+ declare const VERSION = "";
71
+
72
+ type PluginContext = {
73
+ readonly configs: Configs;
74
+ readonly runtime: Runtime;
75
+ readonly cwd: string;
76
+ readonly configFile: string | undefined;
77
+ readonly runAsOnly: boolean;
78
+ readonly results: typeof results;
79
+ readonly timespan: typeof timespan;
80
+ readonly reporter: ReturnType<ReporterPlugin>;
81
+ };
82
+ type PokuPlugin = {
83
+ name?: string;
84
+ runner?: (command: string[], file: string) => string[];
85
+ setup?: (context: PluginContext) => void | Promise<void>;
86
+ teardown?: (context: PluginContext) => void | Promise<void>;
87
+ ipc?: boolean;
88
+ onTestProcess?: (child: ChildProcess, file: string) => void;
89
+ discoverFiles?: (paths: string[], context: PluginContext) => string[] | Promise<string[]>;
90
+ };
91
+ type Results = {
92
+ code: number;
93
+ timespan: Timespan;
94
+ results: typeof results;
95
+ };
96
+ type Path = {
97
+ absolute: string;
98
+ relative: string;
99
+ };
100
+ type ReporterPlugin = (configs?: Configs) => {
101
+ onRunStart: () => void;
102
+ onDescribeAsTitle: (title: string, options?: DescribeOptions) => void;
103
+ onDescribeStart: (options: {
104
+ title?: string;
105
+ }) => void;
106
+ onDescribeEnd: (options: {
107
+ duration: number;
108
+ success?: boolean;
109
+ title?: string;
110
+ }) => void;
111
+ onItStart: (options: {
112
+ title?: string;
113
+ }) => void;
114
+ onItEnd: (options: {
115
+ duration: number;
116
+ success?: boolean;
117
+ title?: string;
118
+ }) => void;
119
+ onAssertionSuccess: (options: {
120
+ message: string;
121
+ }) => void;
122
+ onAssertionFailure: (options: {
123
+ assertOptions: ProcessAssertionOptions;
124
+ error: AssertionError;
125
+ }) => void;
126
+ onSkipFile: (options: {
127
+ message: string;
128
+ }) => void;
129
+ onSkipModifier: (options: {
130
+ message: string;
131
+ }) => void;
132
+ onTodoModifier: (options: {
133
+ message: string;
134
+ }) => void;
135
+ onFileStart: (options: {
136
+ path: Path;
137
+ }) => void;
138
+ onFileResult: (options: {
139
+ status: boolean;
140
+ path: Path;
141
+ duration: number;
142
+ output?: string;
143
+ }) => void;
144
+ onRunResult: (options: Results) => void;
145
+ onExit: (options: Results) => void;
146
+ };
147
+ type ReporterEvents = Partial<ReturnType<ReporterPlugin>>;
148
+ type InspectCLIResult = {
149
+ stdout: string;
150
+ stderr: string;
151
+ exitCode: number;
152
+ process: ChildProcessWithoutNullStreams;
153
+ PID: number;
154
+ kill: () => Promise<void>;
155
+ };
156
+ type ScopeHook = {
157
+ createHolder: () => {
158
+ scope: unknown;
159
+ };
160
+ runScoped: (holder: {
161
+ scope: unknown;
162
+ }, fn: (params?: Record<string, unknown>) => Promise<unknown> | unknown) => Promise<void>;
163
+ };
164
+
165
+ type CustomString = string & NonNullable<unknown>;
166
+ type DenoOptions = {
167
+ allow?: string[];
168
+ deny?: string[];
169
+ };
170
+ type Runtime = 'node' | 'bun' | 'deno';
171
+ type Reporter = 'poku' | 'focus' | 'dot' | 'compact' | 'classic' | ReporterPlugin | CustomString;
172
+ type Configs = {
173
+ noExit?: boolean;
174
+ debug?: boolean;
175
+ quiet?: boolean;
176
+ sequential?: boolean;
177
+ isolation?: 'none' | 'process' | (string & NonNullable<unknown>);
178
+ failFast?: boolean;
179
+ concurrency?: number;
180
+ timeout?: number;
181
+ reporter?: Reporter;
182
+ beforeEach?: () => unknown | Promise<unknown>;
183
+ afterEach?: () => unknown | Promise<unknown>;
184
+ deno?: DenoOptions;
185
+ plugins?: PokuPlugin[];
186
+ testNamePattern?: RegExp;
187
+ testSkipPattern?: RegExp;
188
+ } & Configs$1;
189
+ type Timespan = {
190
+ started: Date;
191
+ finished: Date;
192
+ duration: number;
193
+ };
194
+ type CliConfigs = {
195
+ include?: string | string[];
196
+ envFile?: string;
197
+ kill?: {
198
+ port?: [number];
199
+ range?: [number, number][];
200
+ pid?: [number];
201
+ };
202
+ };
203
+ type ConfigFile = Omit<Configs, 'noExit'> & CliConfigs;
204
+ type Poku = {
205
+ (targetPaths: string | string[], configs: Configs & {
206
+ noExit: true;
207
+ }): Promise<Code>;
208
+ (targetPaths: string | string[], configs?: Configs): Promise<undefined>;
209
+ };
210
+ type TestCb = (params?: Record<string, unknown>) => unknown | Promise<unknown>;
211
+ type AsyncTestCb = (params?: Record<string, unknown>) => Promise<unknown>;
212
+
213
+ declare const onSigint: () => void;
214
+ declare const poku: Poku;
215
+
216
+ export { VERSION, onSigint, poku };
217
+ export type { AssertEqual, AssertMatch, AssertRejects, AssertThrows, AssertValue, AssertionMessage, AsyncTestCb, Code, ConfigFile, Configs$1 as Configs, Configs as Configs$1, Describe, InspectCLIResult, PluginContext, PokuPlugin, ReporterEvents, ReporterPlugin, ScopeHook, TestCb };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.onSigint = void 0;
4
- exports.poku = poku;
3
+ exports.poku = exports.onSigint = void 0;
5
4
  const node_path_1 = require("node:path");
6
5
  const node_process_1 = require("node:process");
7
6
  const poku_js_1 = require("../../configs/poku.js");
@@ -14,7 +13,7 @@ const onSigint = () => {
14
13
  };
15
14
  exports.onSigint = onSigint;
16
15
  process.once('SIGINT', exports.onSigint);
17
- async function poku(targetPaths, configs) {
16
+ exports.poku = (async (targetPaths, configs) => {
18
17
  if (configs)
19
18
  poku_js_1.GLOBAL.configs = { ...poku_js_1.GLOBAL.configs, ...configs };
20
19
  node_process_1.env.POKU_RUNTIME = poku_js_1.GLOBAL.runtime;
@@ -77,4 +76,4 @@ async function poku(targetPaths, configs) {
77
76
  }
78
77
  if (poku_js_1.GLOBAL.configs.noExit)
79
78
  return code;
80
- }
79
+ });
@@ -109,7 +109,6 @@ const backgroundProcess = (runtime, args, file, options) => new Promise((resolve
109
109
  }
110
110
  catch { }
111
111
  });
112
- /** Starts a file in a background process (useful for servers, APIs, etc.) */
113
112
  const startService = (file, options) => {
114
113
  const runtimeOptions = (0, get_runner_js_1.runner)(file);
115
114
  const runtime = runtimeOptions.shift();
@@ -117,14 +116,6 @@ const startService = (file, options) => {
117
116
  return backgroundProcess(runtime, runtimeArgs, (0, node_path_1.normalize)((0, list_files_js_1.sanitizePath)(file)), options);
118
117
  };
119
118
  exports.startService = startService;
120
- /**
121
- *
122
- * Starts a script (package.json) or task (deno.json) in a background process (useful for servers, APIs, etc.).
123
- *
124
- * ---
125
- *
126
- * By default it uses **npm**, but you can costumize it using the `runner` option.
127
- */
128
119
  const startScript = (script, options) => {
129
120
  const runner = options?.runner ?? 'npm';
130
121
  const runtimeOptions = (0, get_runner_js_1.scriptRunner)(runner);
@@ -10,14 +10,14 @@ const indentation_js_1 = require("../../configs/indentation.js");
10
10
  const poku_js_1 = require("../../configs/poku.js");
11
11
  const callback_js_1 = require("../../parsers/callback.js");
12
12
  const get_arg_js_1 = require("../../parsers/get-arg.js");
13
- const core_js_1 = require("./it/core.js");
13
+ const get_test_args_js_1 = require("../../parsers/get-test-args.js");
14
14
  const modifiers_js_1 = require("./modifiers.js");
15
15
  const getOptions = (input) => !input || typeof input !== 'object' ? undefined : input;
16
16
  const describeBase = async (titleOrCb, callbackOrOptions) => {
17
17
  const { reporter } = poku_js_1.GLOBAL;
18
- const title = (0, core_js_1.getTitle)(titleOrCb);
18
+ const title = (0, get_test_args_js_1.getTitle)(titleOrCb);
19
19
  const hasTitle = typeof title === 'string';
20
- const cb = hasTitle ? (0, core_js_1.getCallback)(callbackOrOptions) : (0, core_js_1.getCallback)(titleOrCb);
20
+ const cb = hasTitle ? (0, get_test_args_js_1.getCallback)(callbackOrOptions) : (0, get_test_args_js_1.getCallback)(titleOrCb);
21
21
  const hasCB = typeof cb === 'function';
22
22
  const options = hasCB ? undefined : getOptions(callbackOrOptions);
23
23
  let success = true;
@@ -69,7 +69,7 @@ const describeBase = async (titleOrCb, callbackOrOptions) => {
69
69
  poku_js_1.GLOBAL.runAsOnly = false;
70
70
  };
71
71
  exports.describeBase = describeBase;
72
- async function describeCore(messageOrCb, cbOrOptions) {
72
+ const describeCore = (async (messageOrCb, cbOrOptions) => {
73
73
  if (typeof messageOrCb === 'string' && typeof cbOrOptions !== 'function')
74
74
  return (0, exports.describeBase)(messageOrCb, cbOrOptions);
75
75
  if (get_arg_js_1.hasOnly) {
@@ -85,9 +85,9 @@ async function describeCore(messageOrCb, cbOrOptions) {
85
85
  return (0, exports.describeBase)(messageOrCb, cbOrOptions);
86
86
  if (typeof messageOrCb === 'function')
87
87
  return (0, exports.describeBase)(messageOrCb);
88
- }
88
+ });
89
89
  exports.describe = Object.assign(describeCore, {
90
90
  todo: modifiers_js_1.todo,
91
91
  skip: modifiers_js_1.skip,
92
- only: modifiers_js_1.onlyDescribe,
92
+ only: (0, modifiers_js_1.createOnlyDescribe)(exports.describeBase),
93
93
  });
@@ -2,23 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.afterEach = exports.beforeEach = void 0;
4
4
  const each_js_1 = require("../../configs/each.js");
5
- /**
6
- * Handle **global states** and **external** services before each `test` or `it`.
7
- *
8
- * ---
9
- *
10
- * ```ts
11
- * import { beforeEach } from 'poku';
12
- *
13
- * const before = beforeEach(() => {
14
- * // prepare
15
- * };
16
- *
17
- * before.pause();
18
- * before.continue();
19
- * before.reset();
20
- * ```
21
- */
22
5
  const beforeEach = (callback, options) => {
23
6
  options?.immediate && callback();
24
7
  each_js_1.each.before.cb = () => {
@@ -37,23 +20,6 @@ const beforeEach = (callback, options) => {
37
20
  return { pause, continue: continueFunc, reset };
38
21
  };
39
22
  exports.beforeEach = beforeEach;
40
- /**
41
- * Handle **global states** and **external** services after each `test` or `it`.
42
- *
43
- * ---
44
- *
45
- * ```ts
46
- * import { afterEach } from 'poku';
47
- *
48
- * const after = afterEach(() => {
49
- * // cleanup
50
- * };
51
- *
52
- * after.pause();
53
- * after.continue();
54
- * after.reset();
55
- * ```
56
- */
57
23
  const afterEach = (callback) => {
58
24
  each_js_1.each.after.cb = () => {
59
25
  if (each_js_1.each.after.status)
@@ -8,7 +8,6 @@ const list_files_js_1 = require("./list-files.js");
8
8
  const regex = {
9
9
  comment: /^\s*#/,
10
10
  };
11
- /** Reads an environment file and sets the environment variables. */
12
11
  const envFile = async (filePath = '.env') => {
13
12
  const mapEnv = new Map();
14
13
  const env = await (0, promises_1.readFile)((0, list_files_js_1.sanitizePath)(filePath), 'utf8');
@@ -17,8 +17,6 @@ const getPIDsByRange = (startsAt, endsAt) => {
17
17
  const ports = (0, pid_js_1.populateRange)(startsAt, endsAt);
18
18
  return (0, exports.getPIDs)(ports);
19
19
  };
20
- /** Returns an array containing the ID of all processes listening to the specified port */
21
20
  exports.getPIDs = Object.assign(getPIDsByPorts, {
22
- /** Returns an array containing the ID of all processes listening to the specified port range */
23
21
  range: getPIDsByRange,
24
22
  });
@@ -3,25 +3,22 @@ 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.it = exports.itBase = exports.getCallback = exports.getTitle = void 0;
6
+ exports.it = exports.itBase = void 0;
7
7
  const node_assert_1 = require("node:assert");
8
8
  const node_process_1 = __importDefault(require("node:process"));
9
9
  const each_js_1 = require("../../../configs/each.js");
10
10
  const indentation_js_1 = require("../../../configs/indentation.js");
11
11
  const poku_js_1 = require("../../../configs/poku.js");
12
12
  const get_arg_js_1 = require("../../../parsers/get-arg.js");
13
+ const get_test_args_js_1 = require("../../../parsers/get-test-args.js");
13
14
  const modifiers_js_1 = require("../modifiers.js");
14
15
  const SCOPE_HOOKS_KEY = Symbol.for('@pokujs/poku.test-scope-hooks');
15
- const getTitle = (input) => typeof input === 'string' ? input : undefined;
16
- exports.getTitle = getTitle;
17
- const getCallback = (input) => typeof input === 'function' ? input : undefined;
18
- exports.getCallback = getCallback;
19
16
  const getScopeHook = () => globalThis[SCOPE_HOOKS_KEY];
20
17
  const itBase = async (titleOrCb, callback) => {
21
18
  try {
22
- const title = (0, exports.getTitle)(titleOrCb);
19
+ const title = (0, get_test_args_js_1.getTitle)(titleOrCb);
23
20
  const hasTitle = typeof title === 'string';
24
- const cb = hasTitle ? (0, exports.getCallback)(callback) : (0, exports.getCallback)(titleOrCb);
21
+ const cb = hasTitle ? (0, get_test_args_js_1.getCallback)(callback) : (0, get_test_args_js_1.getCallback)(titleOrCb);
25
22
  let success = true;
26
23
  let start;
27
24
  let end;
@@ -100,7 +97,7 @@ const itBase = async (titleOrCb, callback) => {
100
97
  }
101
98
  };
102
99
  exports.itBase = itBase;
103
- async function itCore(titleOrCb, cb) {
100
+ const itCore = (async (titleOrCb, cb) => {
104
101
  if (poku_js_1.GLOBAL.configs.testNamePattern && typeof titleOrCb === 'string') {
105
102
  if (!poku_js_1.GLOBAL.configs.testNamePattern.test(titleOrCb))
106
103
  return;
@@ -117,9 +114,9 @@ async function itCore(titleOrCb, cb) {
117
114
  return (0, exports.itBase)(titleOrCb, cb);
118
115
  if (typeof titleOrCb === 'function')
119
116
  return (0, exports.itBase)(titleOrCb);
120
- }
117
+ });
121
118
  exports.it = Object.assign(itCore, {
122
119
  todo: modifiers_js_1.todo,
123
120
  skip: modifiers_js_1.skip,
124
- only: modifiers_js_1.onlyIt,
121
+ only: (0, modifiers_js_1.createOnlyIt)(exports.itBase),
125
122
  });
@@ -28,12 +28,8 @@ const killRange = async (startsAt, endsAt) => {
28
28
  await killPID(PID);
29
29
  }
30
30
  };
31
- /** Kill processes by PIDs, ports and port ranges. */
32
31
  exports.kill = {
33
- /** Kill the specified process ID */
34
32
  pid: killPID,
35
- /** Kill all processes listening on the specified port */
36
33
  port: killPort,
37
- /** Kill all processes listening on the specified range ports */
38
34
  range: killRange,
39
35
  };
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.log = void 0;
4
4
  const assert_js_1 = require("../../parsers/assert.js");
5
5
  const write_js_1 = require("../../services/write.js");
6
- /** By default **Poku** only shows outputs generated from itself. This helper allows you to use an alternative to `console.log` with **Poku**. */
7
6
  const log = (...args) => {
8
7
  const parsedMessages = args
9
8
  .map((arg) => (0, assert_js_1.parseResultType)(arg))
@@ -1,26 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.todo = todo;
4
- exports.skip = skip;
5
- exports.onlyDescribe = onlyDescribe;
6
- exports.onlyIt = onlyIt;
3
+ exports.createOnlyIt = exports.createOnlyDescribe = exports.skip = exports.todo = void 0;
7
4
  const node_process_1 = require("node:process");
8
5
  const poku_js_1 = require("../../configs/poku.js");
9
6
  const callback_js_1 = require("../../parsers/callback.js");
10
7
  const get_arg_js_1 = require("../../parsers/get-arg.js");
11
8
  const format_js_1 = require("../../services/format.js");
12
9
  const write_js_1 = require("../../services/write.js");
13
- const describe_js_1 = require("./describe.js");
14
- const core_js_1 = require("./it/core.js");
15
- async function todo(messageOrCb, _cb) {
10
+ exports.todo = (async (messageOrCb, _cb) => {
16
11
  const message = typeof messageOrCb === 'string' ? messageOrCb : 'Planning';
17
12
  poku_js_1.GLOBAL.reporter.onTodoModifier({ message });
18
- }
19
- async function skip(messageOrCb, _cb) {
13
+ });
14
+ exports.skip = (async (messageOrCb, _cb) => {
20
15
  const message = typeof messageOrCb === 'string' ? messageOrCb : 'Skipping';
21
16
  poku_js_1.GLOBAL.reporter.onSkipModifier({ message });
22
- }
23
- async function onlyDescribe(messageOrCb, cb) {
17
+ });
18
+ const createOnlyDescribe = (describeBase) => (async (messageOrCb, cb) => {
24
19
  if (!get_arg_js_1.hasOnly) {
25
20
  (0, write_js_1.log)((0, format_js_1.format)("Can't run `describe.only` tests without `--only` flag").fail());
26
21
  (0, node_process_1.exit)(1);
@@ -29,17 +24,19 @@ async function onlyDescribe(messageOrCb, cb) {
29
24
  if (noItOnly)
30
25
  poku_js_1.GLOBAL.runAsOnly = true;
31
26
  if (typeof messageOrCb === 'string' && cb)
32
- return (0, describe_js_1.describeBase)(messageOrCb, cb);
27
+ return describeBase(messageOrCb, cb);
33
28
  if (typeof messageOrCb === 'function')
34
- return (0, describe_js_1.describeBase)(messageOrCb);
35
- }
36
- async function onlyIt(messageOrCb, cb) {
29
+ return describeBase(messageOrCb);
30
+ });
31
+ exports.createOnlyDescribe = createOnlyDescribe;
32
+ const createOnlyIt = (itBase) => (async (messageOrCb, cb) => {
37
33
  if (!get_arg_js_1.hasOnly) {
38
34
  (0, write_js_1.log)((0, format_js_1.format)("Can't run `it.only` and `test.only` tests without `--only` flag").fail());
39
35
  (0, node_process_1.exit)(1);
40
36
  }
41
37
  if (typeof messageOrCb === 'string' && cb)
42
- return (0, core_js_1.itBase)(messageOrCb, cb);
38
+ return itBase(messageOrCb, cb);
43
39
  if (typeof messageOrCb === 'function')
44
- return (0, core_js_1.itBase)(messageOrCb);
45
- }
40
+ return itBase(messageOrCb);
41
+ });
42
+ exports.createOnlyIt = createOnlyIt;
@@ -11,14 +11,12 @@ const checkPort = (port, host) => new Promise((resolve) => {
11
11
  });
12
12
  client.on('error', () => resolve(false));
13
13
  });
14
- /** Wait until the defined milliseconds. */
15
14
  const sleep = (milliseconds) => {
16
15
  if (!Number.isInteger(milliseconds))
17
16
  throw new Error('Milliseconds must be an integer.');
18
17
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
19
18
  };
20
19
  exports.sleep = sleep;
21
- /** Wait until a result is equal the expected value. */
22
20
  const waitForExpectedResult = async (callback, expectedResult, options) => {
23
21
  const delay = options?.delay || 0;
24
22
  const interval = options?.interval || 100;
@@ -60,7 +58,6 @@ const waitForExpectedResult = async (callback, expectedResult, options) => {
60
58
  await (0, exports.sleep)(delay);
61
59
  };
62
60
  exports.waitForExpectedResult = waitForExpectedResult;
63
- /** Wait until the defined port is active. */
64
61
  const waitForPort = async (port, options) => {
65
62
  const host = options?.host || 'localhost';
66
63
  if (!Number.isInteger(port))