@japa/runner 2.5.0 → 3.0.0-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.
Files changed (54) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/index.d.ts +8 -29
  3. package/build/index.js +95 -458
  4. package/build/src/cli_parser.d.ts +6 -0
  5. package/build/src/cli_parser.d.ts.map +1 -0
  6. package/build/src/cli_parser.js +49 -0
  7. package/build/src/config_manager.d.ts +7 -0
  8. package/build/src/config_manager.d.ts.map +1 -0
  9. package/build/src/config_manager.js +115 -0
  10. package/build/src/create_test.d.ts +16 -0
  11. package/build/src/create_test.d.ts.map +1 -0
  12. package/build/src/create_test.js +33 -0
  13. package/build/src/debug.d.ts +4 -0
  14. package/build/src/debug.d.ts.map +1 -0
  15. package/build/src/debug.js +2 -0
  16. package/build/src/exceptions_manager.d.ts +7 -0
  17. package/build/src/exceptions_manager.d.ts.map +1 -0
  18. package/build/src/exceptions_manager.js +58 -0
  19. package/build/src/files_manager.d.ts +7 -0
  20. package/build/src/files_manager.d.ts.map +1 -0
  21. package/build/src/files_manager.js +28 -0
  22. package/build/src/helpers.d.ts +23 -0
  23. package/build/src/helpers.d.ts.map +1 -0
  24. package/build/src/helpers.js +2 -0
  25. package/build/src/hooks.d.ts +9 -0
  26. package/build/src/hooks.d.ts.map +1 -0
  27. package/build/src/hooks.js +26 -0
  28. package/build/src/planner.d.ts +18 -0
  29. package/build/src/planner.d.ts.map +1 -0
  30. package/build/src/planner.js +67 -0
  31. package/build/src/plugins/retry.d.ts +8 -0
  32. package/build/src/plugins/retry.d.ts.map +1 -0
  33. package/build/src/plugins/retry.js +42 -0
  34. package/build/src/reporters/dot.d.ts +7 -0
  35. package/build/src/reporters/dot.d.ts.map +1 -0
  36. package/build/src/reporters/dot.js +24 -0
  37. package/build/src/reporters/main.d.ts +5 -0
  38. package/build/src/reporters/main.d.ts.map +1 -0
  39. package/build/src/reporters/main.js +21 -0
  40. package/build/src/reporters/ndjson.d.ts +12 -0
  41. package/build/src/reporters/ndjson.d.ts.map +1 -0
  42. package/build/src/reporters/ndjson.js +61 -0
  43. package/build/src/reporters/spec.d.ts +11 -0
  44. package/build/src/reporters/spec.d.ts.map +1 -0
  45. package/build/src/reporters/spec.js +103 -0
  46. package/build/src/types.d.ts +48 -49
  47. package/build/src/types.d.ts.map +1 -0
  48. package/build/src/types.js +1 -10
  49. package/build/src/validator.d.ts +11 -0
  50. package/build/src/validator.d.ts.map +1 -0
  51. package/build/src/validator.js +46 -0
  52. package/package.json +77 -83
  53. package/build/src/core/main.d.ts +0 -32
  54. package/build/src/core/main.js +0 -65
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # The MIT License
2
2
 
3
- Copyright 2022 Harminder Virk, contributors
3
+ Copyright (c) 2023 Harminder Virk
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/build/index.d.ts CHANGED
@@ -1,33 +1,12 @@
1
- import { TestExecutor, ReporterContract } from '@japa/core';
2
- import { Test, TestContext, Group, Suite, Runner } from './src/core/main';
3
- import { Config, PluginFn, RunnerHooksHandler, RunnerHooksCleanupHandler } from './src/types';
4
- export { Test, Config, Suite, Runner, Group, PluginFn, TestContext, ReporterContract, RunnerHooksHandler, RunnerHooksCleanupHandler, };
5
- /**
6
- * Configure the tests runner
7
- */
8
- export declare function configure(options: Config): void;
9
- /**
10
- * Process CLI arguments into configuration options. The following
11
- * command line arguments are processed.
12
- *
13
- * * --tests=Specify test titles
14
- * * --tags=Specify test tags
15
- * * --groups=Specify group titles
16
- * * --ignore-tags=Specify negated tags
17
- * * --files=Specify files to match and run
18
- * * --force-exit=Enable/disable force exit
19
- * * --timeout=Define timeout for all the tests
20
- * * -h, --help=Show help
21
- */
22
- export declare function processCliArgs(argv: string[]): Partial<Config>;
23
- /**
24
- * Run japa tests
25
- */
26
- export declare function run(): Promise<void>;
27
- /**
28
- * Add a new test
29
- */
1
+ import type { TestExecutor } from '@japa/core/types';
2
+ import type { Config } from './src/types.js';
3
+ import { Group, Test, TestContext } from './modules/core/main.js';
30
4
  export declare function test(title: string, callback?: TestExecutor<TestContext, undefined>): Test<undefined>;
31
5
  export declare namespace test {
32
6
  var group: (title: string, callback: (group: Group) => void) => void;
33
7
  }
8
+ export declare function getActiveTest(): Test<any> | undefined;
9
+ export declare function processCLIArgs(argv: string[]): void;
10
+ export declare function configure(options: Config): void;
11
+ export declare function run(): Promise<void>;
12
+ //# sourceMappingURL=index.d.ts.map
package/build/index.js CHANGED
@@ -1,482 +1,119 @@
1
- "use strict";
2
- /*
3
- * @japa/runner
4
- *
5
- * (c) Japa.dev
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- var __importDefault = (this && this.__importDefault) || function (mod) {
11
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ import { fileURLToPath } from 'node:url';
2
+ import { ErrorsPrinter } from '@japa/errors-printer';
3
+ import debug from './src/debug.js';
4
+ import validator from './src/validator.js';
5
+ import { Planner } from './src/planner.js';
6
+ import { GlobalHooks } from './src/hooks.js';
7
+ import { CliParser } from './src/cli_parser.js';
8
+ import { retryPlugin } from './src/plugins/retry.js';
9
+ import { ConfigManager } from './src/config_manager.js';
10
+ import { ExceptionsManager } from './src/exceptions_manager.js';
11
+ import { createTest, createTestGroup } from './src/create_test.js';
12
+ import { Emitter, Runner, Suite } from './modules/core/main.js';
13
+ const emitter = new Emitter();
14
+ let activeTest;
15
+ let cliArgs = {};
16
+ let runnerConfig;
17
+ const executionPlanState = {
18
+ phase: 'idle',
12
19
  };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.test = exports.run = exports.processCliArgs = exports.configure = exports.TestContext = exports.Group = exports.Runner = exports.Suite = exports.Test = void 0;
15
- const getopts_1 = __importDefault(require("getopts"));
16
- const path_1 = require("path");
17
- const fast_glob_1 = __importDefault(require("fast-glob"));
18
- const inclusion_1 = __importDefault(require("inclusion"));
19
- const url_1 = require("url");
20
- const hooks_1 = require("@poppinss/hooks");
21
- const cliui_1 = require("@poppinss/cliui");
22
- const errors_printer_1 = require("@japa/errors-printer");
23
- const core_1 = require("@japa/core");
24
- const main_1 = require("./src/core/main");
25
- Object.defineProperty(exports, "Test", { enumerable: true, get: function () { return main_1.Test; } });
26
- Object.defineProperty(exports, "TestContext", { enumerable: true, get: function () { return main_1.TestContext; } });
27
- Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return main_1.Group; } });
28
- Object.defineProperty(exports, "Suite", { enumerable: true, get: function () { return main_1.Suite; } });
29
- Object.defineProperty(exports, "Runner", { enumerable: true, get: function () { return main_1.Runner; } });
30
- /**
31
- * Filtering layers allowed by the refiner
32
- */
33
- const refinerFilteringLayers = ['tests', 'groups', 'tags'];
34
- /**
35
- * Reference to the recently imported file. We pass it to the
36
- * test and the group both
37
- */
38
- let recentlyImportedFile;
39
- /**
40
- * Global timeout for tests. Fetched from runner options or suites
41
- * options
42
- */
43
- let globalTimeout;
44
- /**
45
- * Function to create the test context for the test
46
- */
47
- const getContext = (testInstance) => new main_1.TestContext(testInstance);
48
- /**
49
- * The global reference to the tests emitter
50
- */
51
- const emitter = new core_1.Emitter();
52
- /**
53
- * Active suite for tests
54
- */
55
- let activeSuite;
56
- /**
57
- * Currently active group
58
- */
59
- let activeGroup;
60
- /**
61
- * Configuration options
62
- */
63
- let runnerOptions;
64
- /**
65
- * Ensure the configure method has been called
66
- */
67
- function ensureIsConfigured(message) {
68
- if (!runnerOptions) {
69
- throw new Error(message);
70
- }
71
- }
72
- /**
73
- * Validate suites filter to ensure a wrong suite is not
74
- * mentioned
75
- */
76
- function validateSuitesFilter() {
77
- if (!('suites' in runnerOptions)) {
78
- return;
79
- }
80
- if (!runnerOptions.filters.suites || !runnerOptions.filters.suites.length) {
81
- return;
82
- }
83
- const suites = runnerOptions.suites.map(({ name }) => name);
84
- const invalidSuites = runnerOptions.filters.suites.filter((suite) => !suites.includes(suite));
85
- if (invalidSuites.length) {
86
- throw new Error(`Unrecognized suite "${invalidSuites[0]}". Make sure to define it in the config first`);
87
- }
88
- }
89
- /**
90
- * Process command line argument into a string value
91
- */
92
- function processAsString(argv, flagName, onMatch) {
93
- const flag = argv[flagName];
94
- if (flag) {
95
- onMatch((Array.isArray(flag) ? flag : flag.split(',')).map((tag) => tag.trim()));
96
- }
97
- }
98
- /**
99
- * Find if the file path matches the files filter array.
100
- * The ending of the file is matched
101
- */
102
- function isFileAllowed(filePath, filters) {
103
- if (!filters.files || !filters.files.length) {
104
- return true;
105
- }
106
- return !!filters.files.find((matcher) => {
107
- if (filePath.endsWith(matcher)) {
108
- return true;
109
- }
110
- return filePath.replace((0, path_1.extname)(filePath), '').endsWith(matcher);
20
+ export function test(title, callback) {
21
+ validator.ensureIsInPlanningPhase(executionPlanState.phase);
22
+ const testInstance = createTest(title, emitter, runnerConfig.refiner, executionPlanState);
23
+ testInstance.setup((t) => {
24
+ activeTest = t;
25
+ return () => {
26
+ activeTest = undefined;
27
+ };
111
28
  });
112
- }
113
- /**
114
- * Returns "true" when no filters are applied or the name is part
115
- * of the applied filter.
116
- */
117
- function isSuiteAllowed(suite, filters) {
118
- if (!filters.suites || !filters.suites.length) {
119
- return true;
120
- }
121
- return filters.suites.includes(suite.name);
122
- }
123
- /**
124
- * Collect files using the files collector function or by processing
125
- * the glob pattern.
126
- *
127
- * The return value is further filtered against the `--files` filter.
128
- */
129
- async function collectFiles(files) {
130
- if (Array.isArray(files) || typeof files === 'string') {
131
- const collectedFiles = await (0, fast_glob_1.default)(files, {
132
- absolute: true,
133
- onlyFiles: true,
134
- cwd: runnerOptions.cwd,
135
- });
136
- return collectedFiles.filter((file) => isFileAllowed(file, runnerOptions.filters));
137
- }
138
- else if (typeof files === 'function') {
139
- const collectedFiles = await files();
140
- return collectedFiles.filter((file) => isFileAllowed(file, runnerOptions.filters));
141
- }
142
- throw new Error('Invalid value for "files" property. Expected a string, array or a function');
143
- }
144
- /**
145
- * Import test files using the configured importer.
146
- */
147
- async function importFiles(files) {
148
- for (let file of files) {
149
- recentlyImportedFile = file;
150
- await runnerOptions.importer(file);
29
+ if (callback) {
30
+ testInstance.run(callback);
151
31
  }
32
+ return testInstance;
152
33
  }
153
- /**
154
- * End tests. We wait for the "beforeExit" event when
155
- * forceExit is not set to true
156
- */
157
- async function endTests(runner) {
158
- if (runnerOptions.forceExit) {
159
- await runner.end();
160
- }
161
- else {
162
- return new Promise((resolve) => {
163
- async function beforeExit() {
164
- process.removeListener('beforeExit', beforeExit);
165
- await runner.end();
166
- resolve();
167
- }
168
- process.on('beforeExit', beforeExit);
169
- });
170
- }
34
+ test.group = function (title, callback) {
35
+ validator.ensureIsInPlanningPhase(executionPlanState.phase);
36
+ executionPlanState.group = createTestGroup(title, emitter, runnerConfig.refiner, executionPlanState);
37
+ callback(executionPlanState.group);
38
+ executionPlanState.group = undefined;
39
+ };
40
+ export function getActiveTest() {
41
+ return activeTest;
171
42
  }
172
- /**
173
- * Show help output in stdout.
174
- */
175
- function showHelp() {
176
- const green = cliui_1.logger.colors.green.bind(cliui_1.logger.colors);
177
- const grey = cliui_1.logger.colors.grey.bind(cliui_1.logger.colors);
178
- console.log(`@japa/runner v2.3.0
179
-
180
- Options:
181
- ${green('--tests')} ${grey('Specify test titles')}
182
- ${green('--tags')} ${grey('Specify test tags')}
183
- ${green('--groups')} ${grey('Specify group titles')}
184
- ${green('--ignore-tags')} ${grey('Specify negated tags')}
185
- ${green('--files')} ${grey('Specify files to match and run')}
186
- ${green('--force-exit')} ${grey('Enable/disable force exit')}
187
- ${green('--timeout')} ${grey('Define timeout for all the tests')}
188
- ${green('-h, --help')} ${grey('Display this message')}
189
-
190
- Examples:
191
- ${grey('$ node bin/test.js --tags="@github"')}
192
- ${grey('$ node bin/test.js --files="example.spec.js" --force-exit')}`);
43
+ export function processCLIArgs(argv) {
44
+ cliArgs = new CliParser().parse(argv);
193
45
  }
194
- /**
195
- * Configure the tests runner
196
- */
197
- function configure(options) {
198
- const defaultOptions = {
199
- cliArgs: {},
200
- cwd: process.cwd(),
201
- files: [],
202
- suites: [],
203
- plugins: [],
204
- reporters: [],
205
- timeout: 2000,
206
- filters: {},
207
- setup: [],
208
- teardown: [],
209
- importer: (filePath) => (0, inclusion_1.default)((0, url_1.pathToFileURL)(filePath).href),
210
- refiner: new core_1.Refiner({}),
211
- forceExit: false,
212
- configureSuite: () => { },
213
- };
214
- runnerOptions = Object.assign(defaultOptions, options);
46
+ export function configure(options) {
47
+ runnerConfig = new ConfigManager(options, cliArgs).hydrate();
215
48
  }
216
- exports.configure = configure;
217
- /**
218
- * Process CLI arguments into configuration options. The following
219
- * command line arguments are processed.
220
- *
221
- * * --tests=Specify test titles
222
- * * --tags=Specify test tags
223
- * * --groups=Specify group titles
224
- * * --ignore-tags=Specify negated tags
225
- * * --files=Specify files to match and run
226
- * * --force-exit=Enable/disable force exit
227
- * * --timeout=Define timeout for all the tests
228
- * * -h, --help=Show help
229
- */
230
- function processCliArgs(argv) {
231
- const parsed = (0, getopts_1.default)(argv, {
232
- string: ['tests', 'tags', 'groups', 'ignoreTags', 'files', 'timeout'],
233
- boolean: ['forceExit', 'help'],
234
- alias: {
235
- ignoreTags: 'ignore-tags',
236
- forceExit: 'force-exit',
237
- help: 'h',
238
- },
239
- });
240
- const config = {
241
- filters: {},
242
- cliArgs: parsed,
243
- };
244
- processAsString(parsed, 'tags', (tags) => (config.filters.tags = tags));
245
- processAsString(parsed, 'ignoreTags', (tags) => {
246
- config.filters.tags = config.filters.tags || [];
247
- tags.forEach((tag) => config.filters.tags.push(`!${tag}`));
248
- });
249
- processAsString(parsed, 'groups', (groups) => (config.filters.groups = groups));
250
- processAsString(parsed, 'tests', (tests) => (config.filters.tests = tests));
251
- processAsString(parsed, 'files', (files) => (config.filters.files = files));
252
- /**
253
- * Show help
254
- */
255
- if (parsed.help) {
256
- showHelp();
257
- process.exit(0);
258
- }
259
- /**
260
- * Get suites
261
- */
262
- if (parsed._.length) {
263
- processAsString({ suites: parsed._ }, 'suites', (suites) => (config.filters.suites = suites));
264
- }
265
- /**
266
- * Get timeout
267
- */
268
- if (parsed.timeout) {
269
- const value = Number(parsed.timeout);
270
- if (!isNaN(value)) {
271
- config.timeout = value;
272
- }
273
- }
274
- /**
275
- * Get forceExit
276
- */
277
- if (parsed.forceExit) {
278
- config.forceExit = true;
49
+ export async function run() {
50
+ if (cliArgs.help) {
51
+ console.log(new CliParser().getHelp());
52
+ return;
279
53
  }
280
- return config;
281
- }
282
- exports.processCliArgs = processCliArgs;
283
- /**
284
- * Run japa tests
285
- */
286
- async function run() {
287
- const runner = new main_1.Runner(emitter);
288
- runner.manageUnHandledExceptions();
289
- runner.onSuite(runnerOptions.configureSuite);
290
- const hooks = new hooks_1.Hooks();
291
- let setupRunner;
292
- let teardownRunner;
54
+ validator.ensureIsConfigured(runnerConfig);
55
+ executionPlanState.phase = 'planning';
56
+ const runner = new Runner(emitter);
57
+ const globalHooks = new GlobalHooks();
58
+ const exceptionsManager = new ExceptionsManager();
293
59
  try {
294
- ensureIsConfigured('Cannot run tests without configuring the tests runner');
295
- /**
296
- * Step 1: Run all plugins
297
- *
298
- * Plugins can also mutate config. So we process the config after
299
- * running plugins only
300
- */
301
- for (let plugin of runnerOptions.plugins) {
302
- await plugin(runnerOptions, runner, { Test: main_1.Test, TestContext: main_1.TestContext, Group: main_1.Group });
60
+ await retryPlugin({ config: runnerConfig, runner, emitter, cliArgs });
61
+ for (let plugin of runnerConfig.plugins) {
62
+ debug('executing "%s" plugin', plugin.name || 'anonymous');
63
+ await plugin({ runner, emitter, cliArgs, config: runnerConfig });
303
64
  }
304
- validateSuitesFilter();
305
- /**
306
- * Step 2: Notify runner about reporters
307
- */
308
- runnerOptions.reporters.forEach((reporter) => runner.registerReporter(reporter));
309
- /**
310
- * Step 3: Configure runner hooks.
311
- */
312
- runnerOptions.setup.forEach((hook) => hooks.add('setup', hook));
313
- runnerOptions.teardown.forEach((hook) => hooks.add('teardown', hook));
314
- setupRunner = hooks.runner('setup');
315
- teardownRunner = hooks.runner('teardown');
316
- /**
317
- * Step 3.1: Run setup hooks
318
- *
319
- * We run the setup hooks before importing test files. It
320
- * allows hooks to setup the app environment for the
321
- * test files.
322
- */
323
- await setupRunner.run(runner);
324
- /**
325
- * Step 4: Entertain files property and import test files
326
- * as part of the default suite
327
- */
328
- if ('files' in runnerOptions && runnerOptions.files.length) {
329
- /**
330
- * Create a default suite for files with no suite
331
- */
332
- globalTimeout = runnerOptions.timeout;
333
- const files = await collectFiles(runnerOptions.files);
334
- /**
335
- * Create and register suite when files are collected.
336
- */
337
- if (files.length) {
338
- activeSuite = new main_1.Suite('default', emitter, runnerOptions.refiner);
339
- runner.add(activeSuite);
340
- await importFiles(files);
65
+ const { config, reporters, suites, refinerFilters } = await new Planner(runnerConfig).plan();
66
+ reporters.forEach((reporter) => {
67
+ debug('registering "%s" reporter', reporter.name);
68
+ runner.registerReporter(reporter);
69
+ });
70
+ refinerFilters.forEach((filter) => {
71
+ debug('apply %s filters "%O" ', filter.layer, filter.filters);
72
+ config.refiner.add(filter.layer, filter.filters);
73
+ });
74
+ config.refiner.matchAllTags(cliArgs.matchAll ?? false);
75
+ runner.onSuite(config.configureSuite);
76
+ debug('executing global hooks');
77
+ globalHooks.apply(config);
78
+ await globalHooks.setup(runner);
79
+ for (let suite of suites) {
80
+ executionPlanState.suite = new Suite(suite.name, emitter, config.refiner);
81
+ executionPlanState.retries = suite.retries;
82
+ executionPlanState.timeout = suite.timeout;
83
+ if (typeof suite.configure === 'function') {
84
+ suite.configure(executionPlanState.suite);
341
85
  }
342
- }
343
- /**
344
- * Step 5: Entertain suites property and import test files
345
- * for the filtered suites.
346
- */
347
- if ('suites' in runnerOptions) {
348
- for (let suite of runnerOptions.suites) {
349
- if (isSuiteAllowed(suite, runnerOptions.filters)) {
350
- if (suite.timeout !== undefined) {
351
- globalTimeout = suite.timeout;
352
- }
353
- else {
354
- globalTimeout = runnerOptions.timeout;
355
- }
356
- const files = await collectFiles(suite.files);
357
- /**
358
- * Only register the suite and import files when the suite
359
- * files glob + filter has returned one or more files.
360
- */
361
- if (files.length) {
362
- activeSuite = new main_1.Suite(suite.name, emitter, runnerOptions.refiner);
363
- if (typeof suite.configure === 'function') {
364
- suite.configure(activeSuite);
365
- }
366
- runner.add(activeSuite);
367
- await importFiles(files);
368
- }
369
- }
86
+ runner.add(executionPlanState.suite);
87
+ for (let fileURL of suite.filesURLs) {
88
+ executionPlanState.file = fileURLToPath(fileURL);
89
+ debug('importing test file %s', executionPlanState.file);
90
+ await config.importer(fileURL);
370
91
  }
92
+ executionPlanState.suite = undefined;
371
93
  }
372
- /**
373
- * Step 6: Add filters to the refiner
374
- */
375
- Object.keys(runnerOptions.filters).forEach((layer) => {
376
- if (refinerFilteringLayers.includes(layer)) {
377
- const values = runnerOptions.filters[layer];
378
- if (values) {
379
- runnerOptions.refiner.add(layer, values);
380
- }
381
- }
382
- });
383
- /**
384
- * Step 7.1: Start the tests runner
385
- */
94
+ executionPlanState.phase = 'executing';
95
+ exceptionsManager.monitor();
386
96
  await runner.start();
387
- /**
388
- * Step 7.2: Execute all the tests
389
- */
390
97
  await runner.exec();
391
- /**
392
- * Step 7.3: Run cleanup and teardown hooks
393
- */
394
- await setupRunner.cleanup(runner);
395
- await teardownRunner.run(runner);
396
- await teardownRunner.cleanup(runner);
397
- /**
398
- * Step 7.4: End or wait for process to exit
399
- */
400
- await endTests(runner);
401
- /**
402
- * Step 8: Update the process exit code
403
- */
98
+ await globalHooks.teardown(null, runner);
99
+ await runner.end();
100
+ await exceptionsManager.flow();
404
101
  const summary = runner.getSummary();
405
- if (summary.hasError) {
102
+ if (summary.hasError || exceptionsManager.hasErrors) {
406
103
  process.exitCode = 1;
407
104
  }
408
- runnerOptions.forceExit && process.exit();
105
+ if (config.forceExit) {
106
+ process.exit();
107
+ }
409
108
  }
410
109
  catch (error) {
411
- if (setupRunner && setupRunner.isCleanupPending) {
412
- await setupRunner.cleanup(error, runner);
413
- }
414
- if (teardownRunner && teardownRunner.isCleanupPending) {
415
- await teardownRunner.cleanup(error, runner);
416
- }
417
- const printer = new errors_printer_1.ErrorsPrinter();
110
+ await globalHooks.teardown(error, runner);
111
+ const printer = new ErrorsPrinter();
418
112
  await printer.printError(error);
113
+ await exceptionsManager.flow();
419
114
  process.exitCode = 1;
420
- runnerOptions.forceExit && process.exit();
421
- }
422
- }
423
- exports.run = run;
424
- /**
425
- * Add a new test
426
- */
427
- function test(title, callback) {
428
- ensureIsConfigured('Cannot add test without configuring the test runner');
429
- const testInstance = new main_1.Test(title, getContext, emitter, runnerOptions.refiner, activeGroup);
430
- /**
431
- * Set filename and suite
432
- */
433
- testInstance.options.meta.suite = activeSuite;
434
- testInstance.options.meta.fileName = recentlyImportedFile;
435
- /**
436
- * Define timeout on the test when exists globally
437
- */
438
- if (globalTimeout !== undefined) {
439
- testInstance.timeout(globalTimeout);
440
- }
441
- /**
442
- * Define test executor function
443
- */
444
- if (callback) {
445
- testInstance.run(callback);
446
- }
447
- /**
448
- * Add test to the group or suite
449
- */
450
- if (activeGroup) {
451
- activeGroup.add(testInstance);
452
- }
453
- else {
454
- activeSuite.add(testInstance);
115
+ if (runnerConfig.forceExit) {
116
+ process.exit();
117
+ }
455
118
  }
456
- return testInstance;
457
119
  }
458
- exports.test = test;
459
- /**
460
- * Define test group
461
- */
462
- test.group = function (title, callback) {
463
- ensureIsConfigured('Cannot add test group without configuring the test runner');
464
- /**
465
- * Disallow nested groups
466
- */
467
- if (activeGroup) {
468
- throw new Error('Cannot create nested test groups');
469
- }
470
- activeGroup = new main_1.Group(title, emitter, runnerOptions.refiner);
471
- /**
472
- * Set filename and suite
473
- */
474
- activeGroup.options.meta.suite = activeSuite;
475
- activeGroup.options.meta.fileName = recentlyImportedFile;
476
- /**
477
- * Add group to the default suite
478
- */
479
- activeSuite.add(activeGroup);
480
- callback(activeGroup);
481
- activeGroup = undefined;
482
- };
@@ -0,0 +1,6 @@
1
+ import type { CLIArgs } from './types.js';
2
+ export declare class CliParser {
3
+ parse(argv: string[]): CLIArgs;
4
+ getHelp(): string;
5
+ }
6
+ //# sourceMappingURL=cli_parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli_parser.d.ts","sourceRoot":"","sources":["../../src/cli_parser.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAsDzC,qBAAa,SAAS;IAIpB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;IAO9B,OAAO;CAGR"}