poku 4.0.0 → 4.0.1-canary.76cf2c4b
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 -3
- package/lib/bin/index.js +1 -1
- package/lib/configs/poku.js +1 -1
- package/lib/modules/essentials/poku.js +5 -0
- package/lib/modules/index.d.ts +1 -1
- package/lib/modules/plugins.d.ts +2 -0
- package/lib/modules/plugins.js +5 -1
- package/lib/plugins/multi-suite/index.d.ts +3 -0
- package/lib/plugins/multi-suite/index.js +78 -0
- package/package.json +3 -2
package/lib/@types/plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AssertionError } from 'node:assert';
|
|
2
2
|
import type { ChildProcess, ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
3
|
-
import type { results } from '../configs/poku.js';
|
|
3
|
+
import type { results, timespan } from '../configs/poku.js';
|
|
4
4
|
import type { ProcessAssertionOptions } from './assert.js';
|
|
5
5
|
import type { DescribeOptions } from './describe.js';
|
|
6
6
|
import type { Configs, Runtime, Timespan } from './poku.js';
|
|
@@ -8,10 +8,15 @@ export type PluginContext = {
|
|
|
8
8
|
readonly configs: Configs;
|
|
9
9
|
readonly runtime: Runtime;
|
|
10
10
|
readonly cwd: string;
|
|
11
|
+
readonly configFile: string | undefined;
|
|
12
|
+
readonly runAsOnly: boolean;
|
|
13
|
+
readonly results: typeof results;
|
|
14
|
+
readonly timespan: typeof timespan;
|
|
15
|
+
readonly reporter: ReturnType<ReporterPlugin>;
|
|
11
16
|
};
|
|
12
17
|
export type PokuPlugin = {
|
|
13
|
-
/**
|
|
14
|
-
name
|
|
18
|
+
/** Plugin name */
|
|
19
|
+
name?: string;
|
|
15
20
|
/** Modify the command array before spawning a test file process */
|
|
16
21
|
runner?: (command: string[], file: string) => string[];
|
|
17
22
|
/** Run before the test suite begins */
|
package/lib/bin/index.js
CHANGED
|
@@ -55,7 +55,7 @@ const write_js_1 = require("../services/write.js");
|
|
|
55
55
|
const value = Number((0, get_arg_js_1.getArg)('timeout'));
|
|
56
56
|
return Number.isNaN(value) ? configsFromFile?.timeout : value;
|
|
57
57
|
})();
|
|
58
|
-
const sequential = (0, get_arg_js_1.hasArg)('sequential');
|
|
58
|
+
const sequential = (0, get_arg_js_1.hasArg)('sequential') || configsFromFile?.sequential;
|
|
59
59
|
if (dirs.length === 1)
|
|
60
60
|
poku_js_1.states.isSinglePath = true;
|
|
61
61
|
if ((0, get_arg_js_1.hasArg)('listFiles')) {
|
package/lib/configs/poku.js
CHANGED
|
@@ -41,6 +41,11 @@ async function poku(targetPaths, configs) {
|
|
|
41
41
|
configs: poku_js_1.GLOBAL.configs,
|
|
42
42
|
runtime: poku_js_1.GLOBAL.runtime,
|
|
43
43
|
cwd: poku_js_1.GLOBAL.cwd,
|
|
44
|
+
configFile: poku_js_1.GLOBAL.configFile,
|
|
45
|
+
runAsOnly: poku_js_1.GLOBAL.runAsOnly,
|
|
46
|
+
results: poku_js_1.results,
|
|
47
|
+
timespan: poku_js_1.timespan,
|
|
48
|
+
reporter: poku_js_1.GLOBAL.reporter,
|
|
44
49
|
};
|
|
45
50
|
for (const plugin of plugins)
|
|
46
51
|
if (plugin.setup)
|
package/lib/modules/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { log } from './helpers/log.js';
|
|
|
17
17
|
export { listFiles } from './helpers/list-files.js';
|
|
18
18
|
export { VERSION as version } from '../configs/poku.js';
|
|
19
19
|
export type { Code } from '../@types/code.js';
|
|
20
|
-
export type { Configs } from '../@types/poku.js';
|
|
20
|
+
export type { Configs, ConfigFile } from '../@types/poku.js';
|
|
21
21
|
export type { StartServiceOptions, StartScriptOptions, } from '../@types/background-process.js';
|
|
22
22
|
export type { WaitForExpectedResultOptions, WaitForPortOptions, } from '../@types/wait-for.js';
|
|
23
23
|
export type { Configs as ListFilesConfigs } from '../@types/list-files.js';
|
package/lib/modules/plugins.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { SpawnOptionsWithoutStdio } from 'node:child_process';
|
|
|
2
2
|
import type { InspectCLIResult, PokuPlugin } from '../@types/plugin.js';
|
|
3
3
|
export { createReporter } from '../builders/reporter.js';
|
|
4
4
|
export { findFileFromStack } from '../parsers/find-file-from-stack.js';
|
|
5
|
+
export { onSigint } from './essentials/poku.js';
|
|
6
|
+
export { reporter as reporterRegistry } from '../services/reporter.js';
|
|
5
7
|
export type { ReporterPlugin, ReporterEvents, PokuPlugin, PluginContext, InspectCLIResult, } from '../@types/plugin.js';
|
|
6
8
|
/** 🐷 Auxiliary function to define a Poku plugin */
|
|
7
9
|
export declare const definePlugin: (plugin: PokuPlugin) => PokuPlugin;
|
package/lib/modules/plugins.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inspectPoku = exports.definePlugin = exports.findFileFromStack = exports.createReporter = void 0;
|
|
3
|
+
exports.inspectPoku = exports.definePlugin = exports.reporterRegistry = exports.onSigint = exports.findFileFromStack = exports.createReporter = void 0;
|
|
4
4
|
const node_child_process_1 = require("node:child_process");
|
|
5
5
|
const node_process_1 = require("node:process");
|
|
6
6
|
const kill_js_1 = require("../modules/helpers/kill.js");
|
|
@@ -10,6 +10,10 @@ var reporter_js_1 = require("../builders/reporter.js");
|
|
|
10
10
|
Object.defineProperty(exports, "createReporter", { enumerable: true, get: function () { return reporter_js_1.createReporter; } });
|
|
11
11
|
var find_file_from_stack_js_1 = require("../parsers/find-file-from-stack.js");
|
|
12
12
|
Object.defineProperty(exports, "findFileFromStack", { enumerable: true, get: function () { return find_file_from_stack_js_1.findFileFromStack; } });
|
|
13
|
+
var poku_js_1 = require("./essentials/poku.js");
|
|
14
|
+
Object.defineProperty(exports, "onSigint", { enumerable: true, get: function () { return poku_js_1.onSigint; } });
|
|
15
|
+
var reporter_js_2 = require("../services/reporter.js");
|
|
16
|
+
Object.defineProperty(exports, "reporterRegistry", { enumerable: true, get: function () { return reporter_js_2.reporter; } });
|
|
13
17
|
/** 🐷 Auxiliary function to define a Poku plugin */
|
|
14
18
|
const definePlugin = (plugin) => plugin;
|
|
15
19
|
exports.definePlugin = definePlugin;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.multiSuite = void 0;
|
|
7
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
8
|
+
const index_js_1 = require("../../modules/index.js");
|
|
9
|
+
const plugins_js_1 = require("../../modules/plugins.js");
|
|
10
|
+
const multiSuite = (suites) => ({
|
|
11
|
+
name: 'multi-suite',
|
|
12
|
+
setup: async (context) => {
|
|
13
|
+
const overallStart = new Date();
|
|
14
|
+
const overallHrtime = node_process_1.default.hrtime();
|
|
15
|
+
const onSignal = () => {
|
|
16
|
+
node_process_1.default.stdout.write('\u001B[?25h');
|
|
17
|
+
node_process_1.default.exit(1);
|
|
18
|
+
};
|
|
19
|
+
node_process_1.default.removeListener('SIGINT', plugins_js_1.onSigint);
|
|
20
|
+
node_process_1.default.once('SIGINT', onSignal);
|
|
21
|
+
let finalCode = 0;
|
|
22
|
+
for (const { include, envFile, kill: suiteKill, ...config } of suites) {
|
|
23
|
+
const dirs = include ? [].concat(include) : ['.'];
|
|
24
|
+
const tasks = [];
|
|
25
|
+
if (envFile)
|
|
26
|
+
tasks.push((0, index_js_1.envFile)(envFile));
|
|
27
|
+
if (suiteKill?.port?.length)
|
|
28
|
+
tasks.push(index_js_1.kill.port(suiteKill.port));
|
|
29
|
+
if (suiteKill?.range?.length) {
|
|
30
|
+
for (const [from, to] of suiteKill.range)
|
|
31
|
+
tasks.push(index_js_1.kill.range(from, to));
|
|
32
|
+
}
|
|
33
|
+
if (suiteKill?.pid?.length)
|
|
34
|
+
tasks.push(index_js_1.kill.pid(suiteKill.pid));
|
|
35
|
+
if (tasks.length)
|
|
36
|
+
await Promise.all(tasks);
|
|
37
|
+
const { reporter: suiteReporterConfig } = config;
|
|
38
|
+
const suiteBase = typeof suiteReporterConfig === 'function'
|
|
39
|
+
? suiteReporterConfig(context.configs)
|
|
40
|
+
: typeof suiteReporterConfig === 'string' &&
|
|
41
|
+
suiteReporterConfig in plugins_js_1.reporterRegistry
|
|
42
|
+
? plugins_js_1.reporterRegistry[suiteReporterConfig](context.configs)
|
|
43
|
+
: context.reporter;
|
|
44
|
+
const suiteReporter = () => ({
|
|
45
|
+
...suiteBase,
|
|
46
|
+
onRunResult() { },
|
|
47
|
+
onExit() { },
|
|
48
|
+
});
|
|
49
|
+
const code = await (0, index_js_1.poku)(dirs, {
|
|
50
|
+
plugins: config.plugins ?? [],
|
|
51
|
+
...config,
|
|
52
|
+
reporter: suiteReporter,
|
|
53
|
+
noExit: true,
|
|
54
|
+
});
|
|
55
|
+
if (code !== 0)
|
|
56
|
+
finalCode = 1;
|
|
57
|
+
}
|
|
58
|
+
const elapsed = node_process_1.default.hrtime(overallHrtime);
|
|
59
|
+
context.timespan.started = overallStart;
|
|
60
|
+
context.timespan.duration = elapsed[0] * 1e3 + elapsed[1] / 1e6;
|
|
61
|
+
context.timespan.finished = new Date();
|
|
62
|
+
if (!context.configs.quiet) {
|
|
63
|
+
context.reporter.onRunResult({
|
|
64
|
+
code: finalCode,
|
|
65
|
+
timespan: context.timespan,
|
|
66
|
+
results: context.results,
|
|
67
|
+
});
|
|
68
|
+
context.reporter.onExit({
|
|
69
|
+
code: finalCode,
|
|
70
|
+
timespan: context.timespan,
|
|
71
|
+
results: context.results,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
node_process_1.default.removeListener('SIGINT', onSignal);
|
|
75
|
+
node_process_1.default.exit(finalCode);
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
exports.multiSuite = multiSuite;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poku",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1-canary.76cf2c4b",
|
|
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
|
"exports": {
|
|
7
7
|
".": "./lib/modules/index.js",
|
|
8
|
-
"./plugins": "./lib/modules/plugins.js"
|
|
8
|
+
"./plugins": "./lib/modules/plugins.js",
|
|
9
|
+
"./plugins/multi-suite": "./lib/plugins/multi-suite/index.js"
|
|
9
10
|
},
|
|
10
11
|
"license": "MIT",
|
|
11
12
|
"bin": {
|