@japa/runner 3.0.0-6 → 3.0.0-8

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 (50) hide show
  1. package/build/chunk-7THDHQFT.js +283 -0
  2. package/build/chunk-HN4AVHWN.js +17 -0
  3. package/build/chunk-MCOW34SG.js +269 -0
  4. package/build/chunk-W5IABAQU.js +502 -0
  5. package/build/factories/main.d.ts +42 -2
  6. package/build/factories/main.js +209 -13
  7. package/build/index.d.ts +14 -9
  8. package/build/index.js +237 -202
  9. package/build/main-63126780.d.ts +109 -0
  10. package/build/modules/core/main.d.ts +3 -62
  11. package/build/modules/core/main.js +21 -121
  12. package/build/src/reporters/main.d.ts +9 -4
  13. package/build/src/reporters/main.js +11 -37
  14. package/build/src/types.d.ts +23 -19
  15. package/build/src/types.js +14 -9
  16. package/package.json +41 -32
  17. package/build/factories/runner.d.ts +0 -27
  18. package/build/factories/runner.js +0 -206
  19. package/build/modules/core/reporters/base.d.ts +0 -41
  20. package/build/modules/core/reporters/base.js +0 -183
  21. package/build/modules/core/types.d.ts +0 -5
  22. package/build/modules/core/types.js +0 -9
  23. package/build/src/cli_parser.d.ts +0 -14
  24. package/build/src/cli_parser.js +0 -75
  25. package/build/src/config_manager.d.ts +0 -18
  26. package/build/src/config_manager.js +0 -168
  27. package/build/src/create_test.d.ts +0 -21
  28. package/build/src/create_test.js +0 -53
  29. package/build/src/debug.d.ts +0 -3
  30. package/build/src/debug.js +0 -10
  31. package/build/src/exceptions_manager.d.ts +0 -19
  32. package/build/src/exceptions_manager.js +0 -85
  33. package/build/src/files_manager.d.ts +0 -18
  34. package/build/src/files_manager.js +0 -57
  35. package/build/src/helpers.d.ts +0 -22
  36. package/build/src/helpers.js +0 -10
  37. package/build/src/hooks.d.ts +0 -20
  38. package/build/src/hooks.js +0 -46
  39. package/build/src/planner.d.ts +0 -25
  40. package/build/src/planner.js +0 -98
  41. package/build/src/plugins/retry.d.ts +0 -20
  42. package/build/src/plugins/retry.js +0 -66
  43. package/build/src/reporters/dot.d.ts +0 -15
  44. package/build/src/reporters/dot.js +0 -41
  45. package/build/src/reporters/ndjson.d.ts +0 -15
  46. package/build/src/reporters/ndjson.js +0 -86
  47. package/build/src/reporters/spec.d.ts +0 -13
  48. package/build/src/reporters/spec.js +0 -154
  49. package/build/src/validator.d.ts +0 -30
  50. package/build/src/validator.js +0 -85
@@ -1,121 +1,21 @@
1
- /*
2
- * @japa/runner
3
- *
4
- * (c) Japa
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { Emitter, Refiner, Test as BaseTest, Suite as BaseSuite, Group as BaseGroup, Runner as BaseRunner, TestContext as BaseTestContext, } from '@japa/core';
10
- import { inspect } from 'node:util';
11
- import { AssertionError } from 'node:assert';
12
- import { BaseReporter } from './reporters/base.js';
13
- export { Emitter, Refiner, BaseReporter };
14
- /**
15
- * Test context carries context data for a given test.
16
- */
17
- export class TestContext extends BaseTestContext {
18
- test;
19
- constructor(test) {
20
- super();
21
- this.test = test;
22
- this.cleanup = (cleanupCallback) => {
23
- test.cleanup(cleanupCallback);
24
- };
25
- }
26
- }
27
- /**
28
- * Test class represents an individual test and exposes API to tweak
29
- * its runtime behavior.
30
- */
31
- export class Test extends BaseTest {
32
- /**
33
- * @inheritdoc
34
- */
35
- static executedCallbacks = [];
36
- /**
37
- * @inheritdoc
38
- */
39
- static executingCallbacks = [];
40
- /**
41
- * Assert the test callback throws an exception when a certain
42
- * error message and optionally is an instance of a given
43
- * Error class.
44
- */
45
- throws(message, errorConstructor) {
46
- const errorInPoint = new AssertionError({});
47
- const existingExecutor = this.options.executor;
48
- if (!existingExecutor) {
49
- throw new Error('Cannot use "test.throws" method without a test callback');
50
- }
51
- /**
52
- * Overwriting existing callback
53
- */
54
- this.options.executor = async (...args) => {
55
- let raisedException;
56
- try {
57
- await existingExecutor(...args);
58
- }
59
- catch (error) {
60
- raisedException = error;
61
- }
62
- /**
63
- * Notify no exception has been raised
64
- */
65
- if (!raisedException) {
66
- errorInPoint.message = 'Expected test to throw an exception';
67
- throw errorInPoint;
68
- }
69
- /**
70
- * Constructor mis-match
71
- */
72
- if (errorConstructor && !(raisedException instanceof errorConstructor)) {
73
- errorInPoint.message = `Expected test to throw "${inspect(errorConstructor)}"`;
74
- throw errorInPoint;
75
- }
76
- /**
77
- * Error does not have a message property
78
- */
79
- const exceptionMessage = raisedException.message;
80
- if (!exceptionMessage || typeof exceptionMessage !== 'string') {
81
- errorInPoint.message = 'Expected test to throw an exception with message property';
82
- throw errorInPoint;
83
- }
84
- /**
85
- * Message does not match
86
- */
87
- if (typeof message === 'string') {
88
- if (exceptionMessage !== message) {
89
- errorInPoint.message = `Expected test to throw "${message}". Instead received "${raisedException.message}"`;
90
- errorInPoint.actual = raisedException.message;
91
- errorInPoint.expected = message;
92
- throw errorInPoint;
93
- }
94
- return;
95
- }
96
- if (!message.test(exceptionMessage)) {
97
- errorInPoint.message = `Expected test error to match "${message}" regular expression`;
98
- throw errorInPoint;
99
- }
100
- };
101
- return this;
102
- }
103
- }
104
- /**
105
- * TestGroup is used to bulk configure a collection of tests and
106
- * define lifecycle hooks for them
107
- */
108
- export class Group extends BaseGroup {
109
- }
110
- /**
111
- * A suite is a collection of tests created around a given
112
- * testing type. For example: A suite for unit tests, a
113
- * suite for functional tests and so on.
114
- */
115
- export class Suite extends BaseSuite {
116
- }
117
- /**
118
- * Runner class is used to execute the tests
119
- */
120
- export class Runner extends BaseRunner {
121
- }
1
+ import {
2
+ BaseReporter,
3
+ Emitter,
4
+ Group,
5
+ Refiner,
6
+ Runner,
7
+ Suite,
8
+ Test,
9
+ TestContext
10
+ } from "../../chunk-MCOW34SG.js";
11
+ import "../../chunk-HN4AVHWN.js";
12
+ export {
13
+ BaseReporter,
14
+ Emitter,
15
+ Group,
16
+ Refiner,
17
+ Runner,
18
+ Suite,
19
+ Test,
20
+ TestContext
21
+ };
@@ -1,13 +1,18 @@
1
- import type { BaseReporterOptions, NamedReporterContract } from '../types.js';
1
+ import { B as BaseReporterOptions } from '../../main-63126780.js';
2
+ import { NamedReporterContract } from '@japa/core/types';
3
+ import '@japa/core';
4
+
2
5
  /**
3
6
  * Create an instance of the spec reporter
4
7
  */
5
- export declare const spec: (options?: BaseReporterOptions) => NamedReporterContract;
8
+ declare const spec: (options?: BaseReporterOptions) => NamedReporterContract;
6
9
  /**
7
10
  * Create an instance of the dot reporter
8
11
  */
9
- export declare const dot: (options?: BaseReporterOptions) => NamedReporterContract;
12
+ declare const dot: (options?: BaseReporterOptions) => NamedReporterContract;
10
13
  /**
11
14
  * Create an instance of the ndjson reporter
12
15
  */
13
- export declare const ndjson: (options?: BaseReporterOptions) => NamedReporterContract;
16
+ declare const ndjson: (options?: BaseReporterOptions) => NamedReporterContract;
17
+
18
+ export { dot, ndjson, spec };
@@ -1,38 +1,12 @@
1
- /*
2
- * @japa/runner
3
- *
4
- * (c) Japa
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { DotReporter } from './dot.js';
10
- import { SpecReporter } from './spec.js';
11
- import { NdJSONReporter } from './ndjson.js';
12
- /**
13
- * Create an instance of the spec reporter
14
- */
15
- export const spec = (options) => {
16
- return {
17
- name: 'spec',
18
- handler: (...args) => new SpecReporter(options).boot(...args),
19
- };
20
- };
21
- /**
22
- * Create an instance of the dot reporter
23
- */
24
- export const dot = (options) => {
25
- return {
26
- name: 'dot',
27
- handler: (...args) => new DotReporter(options).boot(...args),
28
- };
29
- };
30
- /**
31
- * Create an instance of the ndjson reporter
32
- */
33
- export const ndjson = (options) => {
34
- return {
35
- name: 'ndjson',
36
- handler: (...args) => new NdJSONReporter(options).boot(...args),
37
- };
1
+ import {
2
+ dot,
3
+ ndjson,
4
+ spec
5
+ } from "../../chunk-7THDHQFT.js";
6
+ import "../../chunk-MCOW34SG.js";
7
+ import "../../chunk-HN4AVHWN.js";
8
+ export {
9
+ dot,
10
+ ndjson,
11
+ spec
38
12
  };
@@ -1,29 +1,31 @@
1
- /// <reference types="@types/node" resolution-mode="require"/>
2
- import type { HookHandler } from '@poppinss/hooks/types';
3
- import type { Emitter, Refiner, Runner, Suite } from '../modules/core/main.js';
4
- import type { FilteringOptions, NamedReporterContract } from '../modules/core/types.js';
5
- export * from '../modules/core/types.js';
1
+ import { HookHandler } from '@poppinss/hooks/types';
2
+ import { R as Runner, S as Suite } from '../main-63126780.js';
3
+ export { B as BaseReporterOptions } from '../main-63126780.js';
4
+ import { FilteringOptions, NamedReporterContract } from '@japa/core/types';
5
+ export * from '@japa/core/types';
6
+ import { Emitter, Refiner } from '@japa/core';
7
+
6
8
  /**
7
9
  * Global setup hook
8
10
  */
9
- export type SetupHookState = [[runner: Runner], [error: Error | null, runner: Runner]];
10
- export type SetupHookHandler = HookHandler<SetupHookState[0], SetupHookState[1]>;
11
+ type SetupHookState = [[runner: Runner], [error: Error | null, runner: Runner]];
12
+ type SetupHookHandler = HookHandler<SetupHookState[0], SetupHookState[1]>;
11
13
  /**
12
14
  * Global teardown hook
13
15
  */
14
- export type TeardownHookState = [[runner: Runner], [error: Error | null, runner: Runner]];
15
- export type TeardownHookHandler = HookHandler<TeardownHookState[0], TeardownHookState[1]>;
16
+ type TeardownHookState = [[runner: Runner], [error: Error | null, runner: Runner]];
17
+ type TeardownHookHandler = HookHandler<TeardownHookState[0], TeardownHookState[1]>;
16
18
  /**
17
19
  * Global set of available hooks
18
20
  */
19
- export type HooksEvents = {
21
+ type HooksEvents = {
20
22
  setup: SetupHookState;
21
23
  teardown: TeardownHookState;
22
24
  };
23
25
  /**
24
26
  * Parsed command-line arguments
25
27
  */
26
- export type CLIArgs = {
28
+ type CLIArgs = {
27
29
  _?: string[];
28
30
  tags?: string | string[];
29
31
  files?: string | string[];
@@ -40,7 +42,7 @@ export type CLIArgs = {
40
42
  /**
41
43
  * Set of filters you can apply to run only specific tests
42
44
  */
43
- export type Filters = FilteringOptions & {
45
+ type Filters = FilteringOptions & {
44
46
  files?: string[];
45
47
  suites?: string[];
46
48
  };
@@ -48,7 +50,7 @@ export type Filters = FilteringOptions & {
48
50
  * Plugin function receives an instance of the runner,
49
51
  * emitter, config and the hooks
50
52
  */
51
- export type PluginFn = (japa: {
53
+ type PluginFn = (japa: {
52
54
  config: NormalizedConfig;
53
55
  cliArgs: CLIArgs;
54
56
  runner: Runner;
@@ -57,7 +59,7 @@ export type PluginFn = (japa: {
57
59
  /**
58
60
  * Base configuration options
59
61
  */
60
- export type BaseConfig = {
62
+ type BaseConfig = {
61
63
  /**
62
64
  * Current working directory. It is required to search for
63
65
  * the test files
@@ -120,11 +122,11 @@ export type BaseConfig = {
120
122
  * A collection of test files defined as a glob or a callback
121
123
  * function that returns an array of URLs
122
124
  */
123
- export type TestFiles = string | string[] | (() => URL[] | Promise<URL[]>);
125
+ type TestFiles = string | string[] | (() => URL[] | Promise<URL[]>);
124
126
  /**
125
127
  * A test suite to register tests under a named suite
126
128
  */
127
- export type TestSuite = {
129
+ type TestSuite = {
128
130
  /**
129
131
  * A unique name for the suite
130
132
  */
@@ -151,7 +153,7 @@ export type TestSuite = {
151
153
  /**
152
154
  * BaseConfig after normalized by the config manager
153
155
  */
154
- export type NormalizedBaseConfig = Required<Omit<BaseConfig, 'reporters'>> & {
156
+ type NormalizedBaseConfig = Required<Omit<BaseConfig, 'reporters'>> & {
155
157
  reporters: {
156
158
  activated: string[];
157
159
  list: NamedReporterContract[];
@@ -160,7 +162,7 @@ export type NormalizedBaseConfig = Required<Omit<BaseConfig, 'reporters'>> & {
160
162
  /**
161
163
  * Configuration options
162
164
  */
163
- export type Config = BaseConfig & ({
165
+ type Config = BaseConfig & ({
164
166
  files: TestFiles;
165
167
  } | {
166
168
  suites: TestSuite[];
@@ -168,8 +170,10 @@ export type Config = BaseConfig & ({
168
170
  /**
169
171
  * Config after normalized by the config manager
170
172
  */
171
- export type NormalizedConfig = NormalizedBaseConfig & ({
173
+ type NormalizedConfig = NormalizedBaseConfig & ({
172
174
  files: TestFiles;
173
175
  } | {
174
176
  suites: Required<TestSuite>[];
175
177
  });
178
+
179
+ export { BaseConfig, CLIArgs, Config, Filters, HooksEvents, NormalizedBaseConfig, NormalizedConfig, PluginFn, SetupHookHandler, SetupHookState, TeardownHookHandler, TeardownHookState, TestFiles, TestSuite };
@@ -1,9 +1,14 @@
1
- /*
2
- * @japa/runner
3
- *
4
- * (c) Japa
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- export * from '../modules/core/types.js';
1
+ import {
2
+ __reExport
3
+ } from "../chunk-HN4AVHWN.js";
4
+
5
+ // src/types.ts
6
+ var types_exports2 = {};
7
+
8
+ // modules/core/types.ts
9
+ var types_exports = {};
10
+ __reExport(types_exports, types_star);
11
+ import * as types_star from "@japa/core/types";
12
+
13
+ // src/types.ts
14
+ __reExport(types_exports2, types_exports);
package/package.json CHANGED
@@ -1,18 +1,14 @@
1
1
  {
2
2
  "name": "@japa/runner",
3
3
  "description": "Runner for Japa testing framework",
4
- "version": "3.0.0-6",
4
+ "version": "3.0.0-8",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },
8
8
  "main": "build/index.js",
9
9
  "type": "module",
10
10
  "files": [
11
- "build/factories",
12
- "build/modules",
13
- "build/src",
14
- "build/index.d.ts",
15
- "build/index.js"
11
+ "build"
16
12
  ],
17
13
  "exports": {
18
14
  ".": "./build/index.js",
@@ -23,11 +19,11 @@
23
19
  },
24
20
  "scripts": {
25
21
  "pretest": "npm run lint",
26
- "test": "cross-env NODE_ENV=japa:runner c8 npm run quick:test",
22
+ "test": "cross-env NODE_DEBUG=japa:runner c8 npm run quick:test",
27
23
  "quick:test": "glob -c \"node --enable-source-maps --loader=ts-node/esm --test-reporter=spec --test\" \"tests/*.spec.ts\"",
28
24
  "clean": "del-cli build",
29
25
  "typecheck": "tsc --noEmit",
30
- "compile": "npm run lint && npm run clean && tsc",
26
+ "compile": "npm run lint && npm run clean && tsup-node",
31
27
  "build": "npm run compile",
32
28
  "release": "np",
33
29
  "prepublishOnly": "npm run build",
@@ -37,40 +33,39 @@
37
33
  "sync-labels": "github-label-sync --labels .github/labels.json japa/runner"
38
34
  },
39
35
  "devDependencies": {
40
- "@adonisjs/eslint-config": "^1.1.7",
41
- "@adonisjs/prettier-config": "^1.1.7",
42
- "@adonisjs/require-ts": "^2.0.13",
43
- "@adonisjs/tsconfig": "^1.1.7",
44
- "@commitlint/cli": "^17.6.6",
45
- "@commitlint/config-conventional": "^17.6.6",
46
- "@swc/core": "^1.3.68",
47
- "@types/chai": "^4.3.5",
36
+ "@adonisjs/eslint-config": "^1.1.8",
37
+ "@adonisjs/prettier-config": "^1.1.8",
38
+ "@adonisjs/tsconfig": "^1.1.8",
39
+ "@commitlint/cli": "^17.7.1",
40
+ "@commitlint/config-conventional": "^17.7.0",
41
+ "@swc/core": "1.3.82",
42
+ "@types/chai": "^4.3.6",
48
43
  "@types/chai-subset": "^1.3.3",
49
- "@types/find-cache-dir": "^3.2.1",
44
+ "@types/find-cache-dir": "^5.0.0",
50
45
  "@types/ms": "^0.7.31",
51
- "@types/node": "^20.4.1",
52
- "c8": "^8.0.0",
53
- "chai": "^4.3.7",
46
+ "@types/node": "^20.6.3",
47
+ "c8": "^8.0.1",
48
+ "chai": "^4.3.8",
54
49
  "chai-subset": "^1.6.0",
55
50
  "cross-env": "^7.0.3",
56
- "del-cli": "^5.0.0",
57
- "eslint": "^8.44.0",
51
+ "del-cli": "^5.1.0",
52
+ "eslint": "^8.50.0",
58
53
  "github-label-sync": "^2.3.1",
59
- "glob": "^10.3.2",
54
+ "glob": "^10.3.6",
60
55
  "husky": "^8.0.3",
61
- "japa": "^4.0.0",
62
56
  "np": "^8.0.4",
63
- "prettier": "^2.8.8",
57
+ "prettier": "^3.0.3",
64
58
  "ts-node": "^10.9.1",
65
- "typescript": "^5.1.6"
59
+ "tsup": "^7.2.0",
60
+ "typescript": "^5.2.2"
66
61
  },
67
62
  "dependencies": {
68
- "@japa/core": "^8.0.0-9",
69
- "@japa/errors-printer": "^3.0.0-4",
70
- "@poppinss/cliui": "^6.1.1-2",
71
- "@poppinss/hooks": "^7.1.1-3",
72
- "fast-glob": "^3.3.0",
73
- "find-cache-dir": "^4.0.0",
63
+ "@japa/core": "^8.0.0-11",
64
+ "@japa/errors-printer": "^3.0.0-6",
65
+ "@poppinss/colors": "^4.1.0-4",
66
+ "@poppinss/hooks": "^7.1.1-5",
67
+ "fast-glob": "^3.3.1",
68
+ "find-cache-dir": "^5.0.0",
74
69
  "getopts": "^2.3.0",
75
70
  "ms": "^2.1.3",
76
71
  "serialize-error": "^11.0.0",
@@ -125,5 +120,19 @@
125
120
  "modules/core/**",
126
121
  "src/reporters/**"
127
122
  ]
123
+ },
124
+ "tsup": {
125
+ "entry": [
126
+ "./index.ts",
127
+ "./src/types.ts",
128
+ "./src/reporters/main.ts",
129
+ "./factories/main.ts",
130
+ "./modules/core/main.ts"
131
+ ],
132
+ "outDir": "./build",
133
+ "clean": true,
134
+ "format": "esm",
135
+ "dts": true,
136
+ "target": "esnext"
128
137
  }
129
138
  }
@@ -1,27 +0,0 @@
1
- import { Config } from '../src/types.js';
2
- import { Suite, Emitter } from '../modules/core/main.js';
3
- /**
4
- * Runner factory exposes the API to run dummy suites, groups and tests.
5
- * You might want to use the factory for testing reporters and
6
- * plugins usage
7
- */
8
- export declare class RunnerFactory {
9
- #private;
10
- /**
11
- * Configure runner
12
- */
13
- configure(config: Config, argv?: string[]): this;
14
- /**
15
- * Register custom suites to execute instead
16
- * of the dummy one's
17
- */
18
- withSuites(suites: Suite[]): this;
19
- /**
20
- * Define a custom emitter instance to use
21
- */
22
- useEmitter(emitter: Emitter): this;
23
- /**
24
- * Run dummy tests. You might use
25
- */
26
- run(): Promise<import("@japa/core/types").RunnerSummary>;
27
- }