@japa/runner 4.4.1 → 4.5.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/build/index.js CHANGED
@@ -1,238 +1,302 @@
1
- import { a as GlobalHooks, c as debug_default, i as CliParser, n as createTestGroup, o as Planner, r as ConfigManager, s as validator_default, t as createTest } from "./create_test-CuTGNCAf.js";
2
- import { c as Suite, i as Emitter, r as printPinnedTests, s as Runner, t as colors } from "./helpers-BlHaYYTh.js";
3
- import "./main-CB1nhl6c.js";
4
- import { fileURLToPath } from "node:url";
5
- import { ErrorsPrinter } from "@japa/errors-printer";
6
- import { join } from "node:path";
7
- import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
1
+ import {
2
+ CliParser,
3
+ ConfigManager,
4
+ GlobalHooks,
5
+ Planner,
6
+ createTest,
7
+ createTestGroup,
8
+ debug_default,
9
+ validator_default
10
+ } from "./chunk-WNJXMFYL.js";
11
+ import "./chunk-RFKFNXTE.js";
12
+ import {
13
+ Emitter,
14
+ Runner,
15
+ Suite,
16
+ colors,
17
+ printPinnedTests
18
+ } from "./chunk-L7YZLDZD.js";
19
+ import "./chunk-2KG3PWR4.js";
20
+
21
+ // index.ts
22
+ import { fileURLToPath } from "url";
23
+ import { ErrorsPrinter as ErrorsPrinter2 } from "@japa/errors-printer";
24
+
25
+ // src/plugins/retry.ts
26
+ import { join } from "path";
8
27
  import findCacheDirectory from "find-cache-directory";
9
- const CACHE_DIR = findCacheDirectory({ name: "@japa/runner" });
10
- const SUMMARY_FILE = CACHE_DIR ? join(CACHE_DIR, "summary.json") : void 0;
28
+ import { mkdir, readFile, unlink, writeFile } from "fs/promises";
29
+ var CACHE_DIR = findCacheDirectory({ name: "@japa/runner" });
30
+ var SUMMARY_FILE = CACHE_DIR ? join(CACHE_DIR, "summary.json") : void 0;
11
31
  async function getFailedTests() {
12
- try {
13
- const summary = await readFile(SUMMARY_FILE, "utf-8");
14
- return JSON.parse(summary);
15
- } catch (error) {
16
- if (error.code === "ENOENT") return {};
17
- throw new Error("Unable to read failed tests cache file", { cause: error });
18
- }
32
+ try {
33
+ const summary = await readFile(SUMMARY_FILE, "utf-8");
34
+ return JSON.parse(summary);
35
+ } catch (error) {
36
+ if (error.code === "ENOENT") {
37
+ return {};
38
+ }
39
+ throw new Error("Unable to read failed tests cache file", { cause: error });
40
+ }
19
41
  }
20
42
  async function cacheFailedTests(tests) {
21
- await mkdir(CACHE_DIR, { recursive: true });
22
- await writeFile(SUMMARY_FILE, JSON.stringify({ tests }));
43
+ await mkdir(CACHE_DIR, { recursive: true });
44
+ await writeFile(SUMMARY_FILE, JSON.stringify({ tests }));
23
45
  }
24
- const retryPlugin = async function retry({ config, cliArgs: cliArgs$1 }) {
25
- if (!SUMMARY_FILE) return;
26
- config.teardown.push(async (runner) => {
27
- await cacheFailedTests(runner.getSummary().failedTestsTitles);
28
- });
29
- if (cliArgs$1.failed) try {
30
- const { tests } = await getFailedTests();
31
- if (!tests || !tests.length) {
32
- console.log(colors.bgYellow().black(" No failing tests found. Running all the tests "));
33
- return;
34
- }
35
- config.filters.tests = tests;
36
- } catch (error) {
37
- console.log(colors.bgRed().black(" Unable to read failed tests. Running all the tests "));
38
- console.log(colors.red(error));
39
- }
46
+ var retryPlugin = async function retry({ config, cliArgs: cliArgs2 }) {
47
+ if (!SUMMARY_FILE) {
48
+ return;
49
+ }
50
+ config.teardown.push(async (runner) => {
51
+ const summary = runner.getSummary();
52
+ await cacheFailedTests(summary.failedTestsTitles);
53
+ });
54
+ if (cliArgs2.failed) {
55
+ try {
56
+ const { tests } = await getFailedTests();
57
+ if (!tests || !tests.length) {
58
+ console.log(colors.bgYellow().black(" No failing tests found. Running all the tests "));
59
+ return;
60
+ }
61
+ config.filters.tests = tests;
62
+ } catch (error) {
63
+ console.log(colors.bgRed().black(" Unable to read failed tests. Running all the tests "));
64
+ console.log(colors.red(error));
65
+ }
66
+ }
40
67
  };
68
+
69
+ // src/exceptions_manager.ts
70
+ import { ErrorsPrinter } from "@japa/errors-printer";
41
71
  var ExceptionsManager = class {
42
- #exceptionsBuffer = [];
43
- #rejectionsBuffer = [];
44
- #state = "watching";
45
- #errorsPrinter = new ErrorsPrinter({
46
- stackLinesCount: 2,
47
- framesMaxLimit: 4
48
- });
49
- hasErrors = false;
50
- monitor() {
51
- process.on("uncaughtException", async (error) => {
52
- debug_default("received uncaught exception %O", error);
53
- this.hasErrors = true;
54
- if (this.#state === "watching") this.#exceptionsBuffer.push(error);
55
- else {
56
- this.#errorsPrinter.printSectionBorder("[Unhandled Error]");
57
- await this.#errorsPrinter.printError(error);
58
- process.exitCode = 1;
59
- }
60
- });
61
- process.on("unhandledRejection", async (error) => {
62
- debug_default("received unhandled rejection %O", error);
63
- this.hasErrors = true;
64
- if (this.#state === "watching") this.#rejectionsBuffer.push(error);
65
- else {
66
- this.#errorsPrinter.printSectionBorder("[Unhandled Rejection]");
67
- await this.#errorsPrinter.printError(error);
68
- process.exitCode = 1;
69
- }
70
- });
71
- }
72
- async report() {
73
- if (this.#state === "reporting") return;
74
- this.#state = "reporting";
75
- if (this.#exceptionsBuffer.length) {
76
- let exceptionsCount = this.#exceptionsBuffer.length;
77
- let exceptionsIndex = this.#exceptionsBuffer.length;
78
- this.#errorsPrinter.printSectionHeader("Unhandled Errors");
79
- for (let exception of this.#exceptionsBuffer) {
80
- await this.#errorsPrinter.printError(exception);
81
- this.#errorsPrinter.printSectionBorder(`[${++exceptionsIndex}/${exceptionsCount}]`);
82
- }
83
- this.#exceptionsBuffer = [];
84
- }
85
- if (this.#rejectionsBuffer.length) {
86
- let rejectionsCount = this.#exceptionsBuffer.length;
87
- let rejectionsIndex = this.#exceptionsBuffer.length;
88
- this.#errorsPrinter.printSectionBorder("Unhandled Rejections");
89
- for (let rejection of this.#rejectionsBuffer) {
90
- await this.#errorsPrinter.printError(rejection);
91
- this.#errorsPrinter.printSectionBorder(`[${++rejectionsIndex}/${rejectionsCount}]`);
92
- }
93
- this.#rejectionsBuffer = [];
94
- }
95
- }
72
+ #exceptionsBuffer = [];
73
+ #rejectionsBuffer = [];
74
+ #state = "watching";
75
+ #errorsPrinter = new ErrorsPrinter({ stackLinesCount: 2, framesMaxLimit: 4 });
76
+ hasErrors = false;
77
+ /**
78
+ * Monitors unhandled exceptions and rejections. The exceptions
79
+ * are stacked in a buffer, so that we do not clutter the
80
+ * tests output and once the tests are over, we will
81
+ * print them to the console.
82
+ *
83
+ * In case the tests are completed, we will print errors as they
84
+ * happen.
85
+ */
86
+ monitor() {
87
+ process.on("uncaughtException", async (error) => {
88
+ debug_default("received uncaught exception %O", error);
89
+ this.hasErrors = true;
90
+ if (this.#state === "watching") {
91
+ this.#exceptionsBuffer.push(error);
92
+ } else {
93
+ this.#errorsPrinter.printSectionBorder("[Unhandled Error]");
94
+ await this.#errorsPrinter.printError(error);
95
+ process.exitCode = 1;
96
+ }
97
+ });
98
+ process.on("unhandledRejection", async (error) => {
99
+ debug_default("received unhandled rejection %O", error);
100
+ this.hasErrors = true;
101
+ if (this.#state === "watching") {
102
+ this.#rejectionsBuffer.push(error);
103
+ } else {
104
+ this.#errorsPrinter.printSectionBorder("[Unhandled Rejection]");
105
+ await this.#errorsPrinter.printError(error);
106
+ process.exitCode = 1;
107
+ }
108
+ });
109
+ }
110
+ async report() {
111
+ if (this.#state === "reporting") {
112
+ return;
113
+ }
114
+ this.#state = "reporting";
115
+ if (this.#exceptionsBuffer.length) {
116
+ let exceptionsCount = this.#exceptionsBuffer.length;
117
+ let exceptionsIndex = this.#exceptionsBuffer.length;
118
+ this.#errorsPrinter.printSectionHeader("Unhandled Errors");
119
+ for (let exception of this.#exceptionsBuffer) {
120
+ await this.#errorsPrinter.printError(exception);
121
+ this.#errorsPrinter.printSectionBorder(`[${++exceptionsIndex}/${exceptionsCount}]`);
122
+ }
123
+ this.#exceptionsBuffer = [];
124
+ }
125
+ if (this.#rejectionsBuffer.length) {
126
+ let rejectionsCount = this.#exceptionsBuffer.length;
127
+ let rejectionsIndex = this.#exceptionsBuffer.length;
128
+ this.#errorsPrinter.printSectionBorder("Unhandled Rejections");
129
+ for (let rejection of this.#rejectionsBuffer) {
130
+ await this.#errorsPrinter.printError(rejection);
131
+ this.#errorsPrinter.printSectionBorder(`[${++rejectionsIndex}/${rejectionsCount}]`);
132
+ }
133
+ this.#rejectionsBuffer = [];
134
+ }
135
+ }
136
+ };
137
+
138
+ // index.ts
139
+ var emitter = new Emitter();
140
+ var activeTest;
141
+ var cliArgs = {};
142
+ var runnerConfig;
143
+ var executionPlanState = {
144
+ phase: "idle"
96
145
  };
97
- const emitter = new Emitter();
98
- let activeTest;
99
- let cliArgs = {};
100
- let runnerConfig;
101
- const executionPlanState = { phase: "idle" };
102
146
  function test(title, callback) {
103
- validator_default.ensureIsInPlanningPhase(executionPlanState.phase);
104
- const debuggingError = /* @__PURE__ */ new Error();
105
- const testInstance = createTest(title, emitter, runnerConfig.refiner, debuggingError, executionPlanState);
106
- testInstance.setup((t) => {
107
- activeTest = t;
108
- return () => {
109
- activeTest = void 0;
110
- };
111
- });
112
- if (callback) testInstance.run(callback, debuggingError);
113
- return testInstance;
147
+ validator_default.ensureIsInPlanningPhase(executionPlanState.phase);
148
+ const debuggingError = new Error();
149
+ const testInstance = createTest(
150
+ title,
151
+ emitter,
152
+ runnerConfig.refiner,
153
+ debuggingError,
154
+ executionPlanState
155
+ );
156
+ testInstance.setup((t) => {
157
+ activeTest = t;
158
+ return () => {
159
+ activeTest = void 0;
160
+ };
161
+ });
162
+ if (callback) {
163
+ testInstance.run(callback, debuggingError);
164
+ }
165
+ return testInstance;
114
166
  }
115
167
  test.group = function(title, callback) {
116
- validator_default.ensureIsInPlanningPhase(executionPlanState.phase);
117
- const group = createTestGroup(title, emitter, runnerConfig.refiner, executionPlanState);
118
- executionPlanState.group = group;
119
- if (cliArgs.bail && cliArgs.bailLayer === "group") executionPlanState.group.bail(true);
120
- callback(executionPlanState.group);
121
- executionPlanState.group = void 0;
122
- return group;
168
+ validator_default.ensureIsInPlanningPhase(executionPlanState.phase);
169
+ const group = createTestGroup(title, emitter, runnerConfig.refiner, executionPlanState);
170
+ executionPlanState.group = group;
171
+ if (cliArgs.bail && cliArgs.bailLayer === "group") {
172
+ executionPlanState.group.bail(true);
173
+ }
174
+ callback(executionPlanState.group);
175
+ executionPlanState.group = void 0;
176
+ return group;
123
177
  };
124
178
  test.macro = function(callback) {
125
- return (...args) => {
126
- if (!activeTest) throw new Error("Cannot invoke macro outside of the test callback");
127
- return callback(activeTest, ...args);
128
- };
179
+ return (...args) => {
180
+ if (!activeTest) {
181
+ throw new Error("Cannot invoke macro outside of the test callback");
182
+ }
183
+ return callback(activeTest, ...args);
184
+ };
129
185
  };
130
186
  function getActiveTest() {
131
- return activeTest;
187
+ return activeTest;
132
188
  }
133
189
  function getActiveTestOrFail() {
134
- if (!activeTest) throw new Error("Cannot access active test outside of a test callback");
135
- return activeTest;
190
+ if (!activeTest) throw new Error("Cannot access active test outside of a test callback");
191
+ return activeTest;
136
192
  }
137
193
  function processCLIArgs(argv) {
138
- cliArgs = new CliParser().parse(argv);
194
+ cliArgs = new CliParser().parse(argv);
139
195
  }
140
196
  function configure(options) {
141
- runnerConfig = new ConfigManager(options, cliArgs).hydrate();
197
+ runnerConfig = new ConfigManager(options, cliArgs).hydrate();
142
198
  }
143
199
  async function run() {
144
- if (cliArgs.help) {
145
- console.log(new CliParser().getHelp());
146
- return;
147
- }
148
- validator_default.ensureIsConfigured(runnerConfig);
149
- executionPlanState.phase = "planning";
150
- const runner = new Runner(emitter);
151
- if (cliArgs.bail && cliArgs.bailLayer === "") runner.bail(true);
152
- const globalHooks = new GlobalHooks();
153
- const exceptionsManager = new ExceptionsManager();
154
- try {
155
- await retryPlugin({
156
- config: runnerConfig,
157
- runner,
158
- emitter,
159
- cliArgs
160
- });
161
- for (let plugin of runnerConfig.plugins) {
162
- debug_default("executing \"%s\" plugin", plugin.name || "anonymous");
163
- await plugin({
164
- runner,
165
- emitter,
166
- cliArgs,
167
- config: runnerConfig
168
- });
169
- }
170
- const { config, reporters, suites, refinerFilters } = await new Planner(runnerConfig).plan();
171
- reporters.forEach((reporter) => {
172
- debug_default("registering \"%s\" reporter", reporter.name);
173
- runner.registerReporter(reporter);
174
- });
175
- refinerFilters.forEach((filter) => {
176
- debug_default("apply %s filters \"%O\" ", filter.layer, filter.filters);
177
- config.refiner.add(filter.layer, filter.filters);
178
- });
179
- config.refiner.matchAllTags(cliArgs.matchAll ?? false);
180
- runner.onSuite(config.configureSuite);
181
- debug_default("executing global hooks");
182
- globalHooks.apply(config);
183
- if (!cliArgs.listPinned) await globalHooks.setup(runner);
184
- for (let suite of suites) {
185
- debug_default("initiating suite %s", suite.name);
186
- executionPlanState.suite = new Suite(suite.name, emitter, config.refiner);
187
- executionPlanState.retries = suite.retries;
188
- executionPlanState.timeout = suite.timeout;
189
- if (typeof suite.configure === "function") suite.configure(executionPlanState.suite);
190
- if (cliArgs.bail && cliArgs.bailLayer === "suite") {
191
- debug_default("enabling bail mode for the suite %s", suite.name);
192
- executionPlanState.suite.bail(true);
193
- }
194
- runner.add(executionPlanState.suite);
195
- for (let fileURL of suite.filesURLs) {
196
- executionPlanState.file = fileURLToPath(fileURL);
197
- debug_default("importing test file %s", executionPlanState.file);
198
- await config.importer(fileURL);
199
- }
200
- executionPlanState.suite = void 0;
201
- }
202
- if (cliArgs.listPinned) {
203
- printPinnedTests(runner);
204
- if (config.forceExit) {
205
- debug_default("force exiting process");
206
- process.exit();
207
- }
208
- return;
209
- }
210
- executionPlanState.phase = "executing";
211
- exceptionsManager.monitor();
212
- await runner.start();
213
- await runner.exec();
214
- await globalHooks.teardown(null, runner);
215
- await runner.end();
216
- await exceptionsManager.report();
217
- const summary = runner.getSummary();
218
- if (summary.hasError || exceptionsManager.hasErrors) {
219
- debug_default("updating exit code to 1. summary.hasError %s, process.hasError", summary.hasError, exceptionsManager.hasErrors);
220
- process.exitCode = 1;
221
- }
222
- if (config.forceExit) {
223
- debug_default("force exiting process");
224
- process.exit();
225
- }
226
- } catch (error) {
227
- debug_default("error running tests %O", error);
228
- await globalHooks.teardown(error, runner);
229
- await new ErrorsPrinter().printError(error);
230
- await exceptionsManager.report();
231
- process.exitCode = 1;
232
- if (runnerConfig.forceExit) {
233
- debug_default("force exiting process");
234
- process.exit();
235
- }
236
- }
200
+ if (cliArgs.help) {
201
+ console.log(new CliParser().getHelp());
202
+ return;
203
+ }
204
+ validator_default.ensureIsConfigured(runnerConfig);
205
+ executionPlanState.phase = "planning";
206
+ const runner = new Runner(emitter);
207
+ if (cliArgs.bail && cliArgs.bailLayer === "") {
208
+ runner.bail(true);
209
+ }
210
+ const globalHooks = new GlobalHooks();
211
+ const exceptionsManager = new ExceptionsManager();
212
+ try {
213
+ await retryPlugin({ config: runnerConfig, runner, emitter, cliArgs });
214
+ for (let plugin of runnerConfig.plugins) {
215
+ debug_default('executing "%s" plugin', plugin.name || "anonymous");
216
+ await plugin({ runner, emitter, cliArgs, config: runnerConfig });
217
+ }
218
+ const { config, reporters, suites, refinerFilters } = await new Planner(runnerConfig).plan();
219
+ reporters.forEach((reporter) => {
220
+ debug_default('registering "%s" reporter', reporter.name);
221
+ runner.registerReporter(reporter);
222
+ });
223
+ refinerFilters.forEach((filter) => {
224
+ debug_default('apply %s filters "%O" ', filter.layer, filter.filters);
225
+ config.refiner.add(filter.layer, filter.filters);
226
+ });
227
+ config.refiner.matchAllTags(cliArgs.matchAll ?? false);
228
+ runner.onSuite(config.configureSuite);
229
+ debug_default("executing global hooks");
230
+ globalHooks.apply(config);
231
+ if (!cliArgs.listPinned) {
232
+ await globalHooks.setup(runner);
233
+ }
234
+ for (let suite of suites) {
235
+ debug_default("initiating suite %s", suite.name);
236
+ executionPlanState.suite = new Suite(suite.name, emitter, config.refiner);
237
+ executionPlanState.retries = suite.retries;
238
+ executionPlanState.timeout = suite.timeout;
239
+ if (typeof suite.configure === "function") {
240
+ suite.configure(executionPlanState.suite);
241
+ }
242
+ if (cliArgs.bail && cliArgs.bailLayer === "suite") {
243
+ debug_default("enabling bail mode for the suite %s", suite.name);
244
+ executionPlanState.suite.bail(true);
245
+ }
246
+ runner.add(executionPlanState.suite);
247
+ for (let fileURL of suite.filesURLs) {
248
+ executionPlanState.file = fileURLToPath(fileURL);
249
+ debug_default("importing test file %s", executionPlanState.file);
250
+ await config.importer(fileURL);
251
+ }
252
+ executionPlanState.suite = void 0;
253
+ }
254
+ if (cliArgs.listPinned) {
255
+ printPinnedTests(runner);
256
+ if (config.forceExit) {
257
+ debug_default("force exiting process");
258
+ process.exit();
259
+ }
260
+ return;
261
+ }
262
+ executionPlanState.phase = "executing";
263
+ exceptionsManager.monitor();
264
+ await runner.start();
265
+ await runner.exec();
266
+ await globalHooks.teardown(null, runner);
267
+ await runner.end();
268
+ await exceptionsManager.report();
269
+ const summary = runner.getSummary();
270
+ if (summary.hasError || exceptionsManager.hasErrors) {
271
+ debug_default(
272
+ "updating exit code to 1. summary.hasError %s, process.hasError",
273
+ summary.hasError,
274
+ exceptionsManager.hasErrors
275
+ );
276
+ process.exitCode = 1;
277
+ }
278
+ if (config.forceExit) {
279
+ debug_default("force exiting process");
280
+ process.exit();
281
+ }
282
+ } catch (error) {
283
+ debug_default("error running tests %O", error);
284
+ await globalHooks.teardown(error, runner);
285
+ const printer = new ErrorsPrinter2();
286
+ await printer.printError(error);
287
+ await exceptionsManager.report();
288
+ process.exitCode = 1;
289
+ if (runnerConfig.forceExit) {
290
+ debug_default("force exiting process");
291
+ process.exit();
292
+ }
293
+ }
237
294
  }
238
- export { configure, getActiveTest, getActiveTestOrFail, processCLIArgs, run, test };
295
+ export {
296
+ configure,
297
+ getActiveTest,
298
+ getActiveTestOrFail,
299
+ processCLIArgs,
300
+ run,
301
+ test
302
+ };
@@ -1,2 +1,21 @@
1
- import { a as Group, c as Suite, d as BaseReporter, i as Emitter, l as Test, o as Refiner, s as Runner, u as TestContext } from "../../helpers-BlHaYYTh.js";
2
- export { BaseReporter, Emitter, Group, Refiner, Runner, Suite, Test, TestContext };
1
+ import {
2
+ BaseReporter,
3
+ Emitter,
4
+ Group,
5
+ Refiner,
6
+ Runner,
7
+ Suite,
8
+ Test,
9
+ TestContext
10
+ } from "../../chunk-L7YZLDZD.js";
11
+ import "../../chunk-2KG3PWR4.js";
12
+ export {
13
+ BaseReporter,
14
+ Emitter,
15
+ Group,
16
+ Refiner,
17
+ Runner,
18
+ Suite,
19
+ Test,
20
+ TestContext
21
+ };
@@ -1,4 +1,4 @@
1
- import { type Emitter, type Runner } from '../main.js';
1
+ import { Emitter, Runner } from '../main.js';
2
2
  import type { TestEndNode, SuiteEndNode, GroupEndNode, TestStartNode, RunnerSummary, RunnerEndNode, GroupStartNode, SuiteStartNode, RunnerStartNode, BaseReporterOptions } from '../types.js';
3
3
  /**
4
4
  * Base reporter to build custom reporters on top of
@@ -1,4 +1,4 @@
1
- import { type Emitter, Group, type Refiner, type Suite, Test } from '../modules/core/main.js';
1
+ import { Emitter, Group, Refiner, Suite, Test } from '../modules/core/main.js';
2
2
  /**
3
3
  * Create a new instance of the Test
4
4
  */
@@ -1,2 +1,2 @@
1
- declare const _default: import("node:util").DebugLogger;
1
+ declare const _default: import("util").DebugLogger;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
- import { type Colors } from '@poppinss/colors/types';
2
- import { type Runner, type Test } from '../modules/core/main.js';
1
+ import { Colors } from '@poppinss/colors/types';
2
+ import { Runner, Test } from '../modules/core/main.js';
3
3
  export declare const colors: Colors;
4
4
  /**
5
5
  * A collection of platform specific icons
@@ -1,4 +1,4 @@
1
- import { type Runner } from '../modules/core/main.js';
1
+ import { Runner } from '../modules/core/main.js';
2
2
  import type { NormalizedConfig } from './types.js';
3
3
  /**
4
4
  * Exposes API for working with global hooks
@@ -1,23 +1,31 @@
1
+ import "../../chunk-2KG3PWR4.js";
2
+
3
+ // src/plugins/disallow_pinned_tests.ts
1
4
  import string from "@poppinss/string";
2
5
  function disallowPinnedTests(options) {
3
- const disallow = options?.disallow ?? true;
4
- const errorMessage = options?.errorMessage ?? "Pinning tests are disallowed by the \"disallowPinnedTests\" plugin. Use the \"--list-pinned\" flag to list pinned tests";
5
- return async function disallowPinnedTestsPluginFn({ runner, emitter }) {
6
- if (!disallow) return;
7
- function disallowPinned(test) {
8
- if (test.isPinned) {
9
- test.options.meta.abort(string.interpolate(errorMessage, { test: test.title }));
10
- process.exitCode = 1;
11
- }
12
- }
13
- emitter.on("runner:start", () => {
14
- runner.onSuite((suite) => {
15
- suite.onGroup((group) => {
16
- group.tap(disallowPinned);
17
- });
18
- suite.onTest(disallowPinned);
19
- });
20
- });
21
- };
6
+ const disallow = options?.disallow ?? true;
7
+ const errorMessage = options?.errorMessage ?? 'Pinning tests are disallowed by the "disallowPinnedTests" plugin. Use the "--list-pinned" flag to list pinned tests';
8
+ const pluginFn = async function disallowPinnedTestsPluginFn({ runner, emitter }) {
9
+ if (!disallow) {
10
+ return;
11
+ }
12
+ function disallowPinned(test) {
13
+ if (test.isPinned) {
14
+ test.options.meta.abort(string.interpolate(errorMessage, { test: test.title }));
15
+ process.exitCode = 1;
16
+ }
17
+ }
18
+ emitter.on("runner:start", () => {
19
+ runner.onSuite((suite) => {
20
+ suite.onGroup((group) => {
21
+ group.tap(disallowPinned);
22
+ });
23
+ suite.onTest(disallowPinned);
24
+ });
25
+ });
26
+ };
27
+ return pluginFn;
22
28
  }
23
- export { disallowPinnedTests };
29
+ export {
30
+ disallowPinnedTests
31
+ };
@@ -1,3 +1,14 @@
1
- import "../../helpers-BlHaYYTh.js";
2
- import { i as spec, n as github, r as ndjson, t as dot } from "../../main-CB1nhl6c.js";
3
- export { dot, github, ndjson, spec };
1
+ import {
2
+ dot,
3
+ github,
4
+ ndjson,
5
+ spec
6
+ } from "../../chunk-RFKFNXTE.js";
7
+ import "../../chunk-L7YZLDZD.js";
8
+ import "../../chunk-2KG3PWR4.js";
9
+ export {
10
+ dot,
11
+ github,
12
+ ndjson,
13
+ spec
14
+ };