poku 4.2.1 → 4.2.2-canary.7b82ad1d
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/lib/@types/plugin.d.ts +8 -0
- package/lib/@types/poku.d.ts +1 -0
- package/lib/configs/poku.js +1 -1
- package/lib/modules/helpers/it/core.d.ts +7 -6
- package/lib/modules/helpers/it/core.js +13 -6
- package/lib/modules/helpers/test.d.ts +4 -4
- package/lib/modules/plugins.d.ts +1 -1
- package/package.json +1 -1
package/lib/@types/plugin.d.ts
CHANGED
|
@@ -95,4 +95,12 @@ export type InspectCLIResult = {
|
|
|
95
95
|
PID: number;
|
|
96
96
|
kill: () => Promise<void>;
|
|
97
97
|
};
|
|
98
|
+
export type ScopeHook = {
|
|
99
|
+
createHolder: () => {
|
|
100
|
+
scope: unknown;
|
|
101
|
+
};
|
|
102
|
+
runScoped: (holder: {
|
|
103
|
+
scope: unknown;
|
|
104
|
+
}, fn: (params?: Record<string, unknown>) => Promise<unknown> | unknown) => Promise<void>;
|
|
105
|
+
};
|
|
98
106
|
export {};
|
package/lib/@types/poku.d.ts
CHANGED
|
@@ -145,3 +145,4 @@ export type ConfigJSONFile = {
|
|
|
145
145
|
testSkipPattern?: string;
|
|
146
146
|
} & Omit<Configs, 'beforeEach' | 'afterEach' | 'noExit' | 'filter' | 'exclude' | 'plugins' | 'testNamePattern' | 'testSkipPattern'> & CliConfigs;
|
|
147
147
|
export type ConfigFile = Omit<Configs, 'noExit'> & CliConfigs;
|
|
148
|
+
export type TestCallback = (params?: Record<string, unknown>) => unknown | Promise<unknown>;
|
package/lib/configs/poku.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { TestCallback } from '../../../@types/poku.js';
|
|
1
2
|
import { onlyIt, skip, todo } from '../modifiers.js';
|
|
2
3
|
export declare const getTitle: (input: unknown) => string | undefined;
|
|
3
|
-
export declare const getCallback: (input: unknown) =>
|
|
4
|
-
export declare const itBase: (titleOrCb: string |
|
|
5
|
-
declare function itCore(title: string, cb:
|
|
6
|
-
declare function itCore(title: string, cb:
|
|
7
|
-
declare function itCore(cb:
|
|
8
|
-
declare function itCore(cb:
|
|
4
|
+
export declare const getCallback: (input: unknown) => TestCallback | undefined;
|
|
5
|
+
export declare const itBase: (titleOrCb: string | TestCallback, callback?: TestCallback) => Promise<void>;
|
|
6
|
+
declare function itCore(title: string, cb: TestCallback): Promise<void>;
|
|
7
|
+
declare function itCore(title: string, cb: TestCallback): void;
|
|
8
|
+
declare function itCore(cb: TestCallback): Promise<void>;
|
|
9
|
+
declare function itCore(cb: TestCallback): void;
|
|
9
10
|
export declare const it: typeof itCore & {
|
|
10
11
|
todo: typeof todo;
|
|
11
12
|
skip: typeof skip;
|
|
@@ -11,12 +11,12 @@ 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
13
|
const modifiers_js_1 = require("../modifiers.js");
|
|
14
|
+
const SCOPE_HOOKS_KEY = Symbol.for('@pokujs/poku.test-scope-hooks');
|
|
14
15
|
const getTitle = (input) => typeof input === 'string' ? input : undefined;
|
|
15
16
|
exports.getTitle = getTitle;
|
|
16
|
-
const getCallback = (input) => typeof input === 'function'
|
|
17
|
-
? input
|
|
18
|
-
: undefined;
|
|
17
|
+
const getCallback = (input) => typeof input === 'function' ? input : undefined;
|
|
19
18
|
exports.getCallback = getCallback;
|
|
19
|
+
const getScopeHook = () => globalThis[SCOPE_HOOKS_KEY];
|
|
20
20
|
const itBase = async (titleOrCb, callback) => {
|
|
21
21
|
try {
|
|
22
22
|
const title = (0, exports.getTitle)(titleOrCb);
|
|
@@ -49,9 +49,16 @@ const itBase = async (titleOrCb, callback) => {
|
|
|
49
49
|
poku_js_1.errorHoist.failed = false;
|
|
50
50
|
start = node_process_1.default.hrtime();
|
|
51
51
|
try {
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
|
|
52
|
+
const hooks = getScopeHook();
|
|
53
|
+
if (hooks) {
|
|
54
|
+
const holder = hooks.createHolder();
|
|
55
|
+
await hooks.runScoped(holder, (params) => cb(params));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const resultCb = cb();
|
|
59
|
+
if (resultCb instanceof Promise)
|
|
60
|
+
await resultCb;
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
63
|
catch (error) {
|
|
57
64
|
node_process_1.default.exitCode = 1;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const test: {
|
|
2
|
-
(title: string, cb: ()
|
|
3
|
-
(title: string, cb: ()
|
|
4
|
-
(cb: ()
|
|
5
|
-
(cb: ()
|
|
2
|
+
(title: string, cb: import("../../@types/poku.js").TestCallback): Promise<void>;
|
|
3
|
+
(title: string, cb: import("../../@types/poku.js").TestCallback): void;
|
|
4
|
+
(cb: import("../../@types/poku.js").TestCallback): Promise<void>;
|
|
5
|
+
(cb: import("../../@types/poku.js").TestCallback): void;
|
|
6
6
|
} & {
|
|
7
7
|
todo: typeof import("./modifiers.js").todo;
|
|
8
8
|
skip: typeof import("./modifiers.js").skip;
|
package/lib/modules/plugins.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { createReporter } from '../builders/reporter.js';
|
|
|
4
4
|
export { findFileFromStack } from '../parsers/find-file-from-stack.js';
|
|
5
5
|
export { onSigint } from './essentials/poku.js';
|
|
6
6
|
export { reporter as reporterRegistry } from '../services/reporter.js';
|
|
7
|
-
export type { ReporterPlugin, ReporterEvents, PokuPlugin, PluginContext, InspectCLIResult, } from '../@types/plugin.js';
|
|
7
|
+
export type { ReporterPlugin, ReporterEvents, PokuPlugin, PluginContext, InspectCLIResult, ScopeHook, } from '../@types/plugin.js';
|
|
8
8
|
/** 🐷 Auxiliary function to define a Poku plugin */
|
|
9
9
|
export declare const definePlugin: (plugin: PokuPlugin) => PokuPlugin;
|
|
10
10
|
/** 🐽 Auxiliary function to inspect a Poku CLI execution */
|