@japa/runner 4.2.0 → 4.3.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.
@@ -8,8 +8,8 @@ import {
8
8
  Runner as BaseRunner,
9
9
  TestContext as BaseTestContext
10
10
  } from "@japa/core";
11
- import { inspect } from "node:util";
12
- import { AssertionError } from "node:assert";
11
+ import { inspect } from "util";
12
+ import { AssertionError } from "assert";
13
13
 
14
14
  // modules/core/reporters/base.ts
15
15
  import ms from "ms";
@@ -2,7 +2,7 @@ import {
2
2
  BaseReporter,
3
3
  colors,
4
4
  icons
5
- } from "./chunk-CYGUHLQ7.js";
5
+ } from "./chunk-PCBL2VZP.js";
6
6
 
7
7
  // src/reporters/dot.ts
8
8
  var DotReporter = class extends BaseReporter {
@@ -35,7 +35,7 @@ var DotReporter = class extends BaseReporter {
35
35
 
36
36
  // src/reporters/spec.ts
37
37
  import ms from "ms";
38
- import { relative } from "node:path";
38
+ import { relative } from "path";
39
39
  var SpecReporter = class extends BaseReporter {
40
40
  /**
41
41
  * Tracking if the first event we get is for a test without any parent group
@@ -155,7 +155,7 @@ ${colors.dim(this.#getRelativeFilename(this.currentFileName))}`);
155
155
  };
156
156
 
157
157
  // src/reporters/ndjson.ts
158
- import { relative as relative2 } from "node:path";
158
+ import { relative as relative2 } from "path";
159
159
  import { serializeError } from "serialize-error";
160
160
  var NdJSONReporter = class extends BaseReporter {
161
161
  /**
@@ -241,8 +241,8 @@ var NdJSONReporter = class extends BaseReporter {
241
241
 
242
242
  // src/reporters/github.ts
243
243
  import slash from "slash";
244
- import { relative as relative3 } from "node:path";
245
- import { stripVTControlCharacters } from "node:util";
244
+ import { relative as relative3 } from "path";
245
+ import { stripVTControlCharacters } from "util";
246
246
  import { ErrorsPrinter } from "@japa/errors-printer";
247
247
  var GithubReporter = class extends BaseReporter {
248
248
  /**
@@ -3,17 +3,17 @@ import {
3
3
  github,
4
4
  ndjson,
5
5
  spec
6
- } from "./chunk-DPWXK7IV.js";
6
+ } from "./chunk-U3BSXCEH.js";
7
7
  import {
8
8
  Group,
9
9
  Refiner,
10
10
  Test,
11
11
  TestContext,
12
12
  colors
13
- } from "./chunk-CYGUHLQ7.js";
13
+ } from "./chunk-PCBL2VZP.js";
14
14
 
15
15
  // src/debug.ts
16
- import { debuglog } from "node:util";
16
+ import { debuglog } from "util";
17
17
  var debug_default = debuglog("japa:runner");
18
18
 
19
19
  // src/validator.ts
@@ -91,7 +91,7 @@ var validator_default = new Validator();
91
91
  // src/files_manager.ts
92
92
  import slash from "slash";
93
93
  import fastGlob from "fast-glob";
94
- import { pathToFileURL } from "node:url";
94
+ import { pathToFileURL } from "url";
95
95
  var FILE_SUFFIX_EXPRESSION = /(\.spec|\.test)?\.[js|ts|jsx|tsx|mjs|mts|cjs|cts]+$/;
96
96
  var FilesManager = class {
97
97
  /**
@@ -5,17 +5,17 @@ import {
5
5
  Planner,
6
6
  createTest,
7
7
  createTestGroup
8
- } from "../chunk-WEAHCEFK.js";
9
- import "../chunk-DPWXK7IV.js";
8
+ } from "../chunk-Y57JXJ7G.js";
9
+ import "../chunk-U3BSXCEH.js";
10
10
  import {
11
11
  Emitter,
12
12
  Runner,
13
13
  Suite
14
- } from "../chunk-CYGUHLQ7.js";
14
+ } from "../chunk-PCBL2VZP.js";
15
15
  import "../chunk-2KG3PWR4.js";
16
16
 
17
17
  // factories/runner.ts
18
- import { fileURLToPath } from "node:url";
18
+ import { fileURLToPath } from "url";
19
19
  var RunnerFactory = class {
20
20
  #emitter = new Emitter();
21
21
  #config;
@@ -100,7 +100,7 @@ var RunnerFactory = class {
100
100
  };
101
101
 
102
102
  // factories/create_dummy_tests.ts
103
- import assert from "node:assert";
103
+ import assert from "assert";
104
104
  function createUnitTestsSuite(emitter, refiner, file) {
105
105
  const suite = new Suite("unit", emitter, refiner);
106
106
  const group = createTestGroup("Maths#add", emitter, refiner, {
package/build/index.d.ts CHANGED
@@ -8,13 +8,17 @@ type OmitFirstArg<F> = F extends [_: any, ...args: infer R] ? R : never;
8
8
  */
9
9
  export declare function test(title: string, callback?: TestExecutor<TestContext, undefined>): Test<undefined>;
10
10
  export declare namespace test {
11
- var group: (title: string, callback: (group: Group) => void) => void;
11
+ var group: (title: string, callback: (group: Group) => void) => Group;
12
12
  var macro: <T extends (test: Test, ...args: any[]) => any>(callback: T) => (...args: OmitFirstArg<Parameters<T>>) => ReturnType<T>;
13
13
  }
14
14
  /**
15
15
  * Get the test of currently running test
16
16
  */
17
17
  export declare function getActiveTest(): Test<any> | undefined;
18
+ /**
19
+ * Get the test of currently running test or throw an error
20
+ */
21
+ export declare function getActiveTestOrFail(): Test<any>;
18
22
  /**
19
23
  * Make Japa process command line arguments. Later the parsed output
20
24
  * will be used by Japa to compute the configuration
package/build/index.js CHANGED
@@ -7,24 +7,24 @@ import {
7
7
  createTestGroup,
8
8
  debug_default,
9
9
  validator_default
10
- } from "./chunk-WEAHCEFK.js";
11
- import "./chunk-DPWXK7IV.js";
10
+ } from "./chunk-Y57JXJ7G.js";
11
+ import "./chunk-U3BSXCEH.js";
12
12
  import {
13
13
  Emitter,
14
14
  Runner,
15
15
  Suite,
16
16
  colors
17
- } from "./chunk-CYGUHLQ7.js";
17
+ } from "./chunk-PCBL2VZP.js";
18
18
  import "./chunk-2KG3PWR4.js";
19
19
 
20
20
  // index.ts
21
- import { fileURLToPath } from "node:url";
21
+ import { fileURLToPath } from "url";
22
22
  import { ErrorsPrinter as ErrorsPrinter2 } from "@japa/errors-printer";
23
23
 
24
24
  // src/plugins/retry.ts
25
- import { join } from "node:path";
25
+ import { join } from "path";
26
26
  import findCacheDirectory from "find-cache-dir";
27
- import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
27
+ import { mkdir, readFile, unlink, writeFile } from "fs/promises";
28
28
  var CACHE_DIR = findCacheDirectory({ name: "@japa/runner" });
29
29
  var SUMMARY_FILE = CACHE_DIR ? join(CACHE_DIR, "summary.json") : void 0;
30
30
  async function getFailedTests() {
@@ -158,17 +158,14 @@ function test(title, callback) {
158
158
  }
159
159
  test.group = function(title, callback) {
160
160
  validator_default.ensureIsInPlanningPhase(executionPlanState.phase);
161
- executionPlanState.group = createTestGroup(
162
- title,
163
- emitter,
164
- runnerConfig.refiner,
165
- executionPlanState
166
- );
161
+ const group = createTestGroup(title, emitter, runnerConfig.refiner, executionPlanState);
162
+ executionPlanState.group = group;
167
163
  if (cliArgs.bail && cliArgs.bailLayer === "group") {
168
164
  executionPlanState.group.bail(true);
169
165
  }
170
166
  callback(executionPlanState.group);
171
167
  executionPlanState.group = void 0;
168
+ return group;
172
169
  };
173
170
  test.macro = function(callback) {
174
171
  return (...args) => {
@@ -181,6 +178,10 @@ test.macro = function(callback) {
181
178
  function getActiveTest() {
182
179
  return activeTest;
183
180
  }
181
+ function getActiveTestOrFail() {
182
+ if (!activeTest) throw new Error("Cannot access active test outside of a test callback");
183
+ return activeTest;
184
+ }
184
185
  function processCLIArgs(argv) {
185
186
  cliArgs = new CliParser().parse(argv);
186
187
  }
@@ -276,6 +277,7 @@ async function run() {
276
277
  export {
277
278
  configure,
278
279
  getActiveTest,
280
+ getActiveTestOrFail,
279
281
  processCLIArgs,
280
282
  run,
281
283
  test
@@ -7,7 +7,7 @@ import {
7
7
  Suite,
8
8
  Test,
9
9
  TestContext
10
- } from "../../chunk-CYGUHLQ7.js";
10
+ } from "../../chunk-PCBL2VZP.js";
11
11
  import "../../chunk-2KG3PWR4.js";
12
12
  export {
13
13
  BaseReporter,
@@ -3,8 +3,8 @@ import {
3
3
  github,
4
4
  ndjson,
5
5
  spec
6
- } from "../../chunk-DPWXK7IV.js";
7
- import "../../chunk-CYGUHLQ7.js";
6
+ } from "../../chunk-U3BSXCEH.js";
7
+ import "../../chunk-PCBL2VZP.js";
8
8
  import "../../chunk-2KG3PWR4.js";
9
9
  export {
10
10
  dot,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@japa/runner",
3
3
  "description": "A simple yet powerful testing framework for Node.js",
4
- "version": "4.2.0",
4
+ "version": "4.3.0",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },
@@ -35,36 +35,34 @@
35
35
  "quick:test": "glob -c \"node --import=ts-node-maintained/register/esm --enable-source-maps --test-reporter=spec --test\" \"tests/*.spec.ts\""
36
36
  },
37
37
  "devDependencies": {
38
- "@adonisjs/eslint-config": "^2.0.0-beta.7",
39
- "@adonisjs/prettier-config": "^1.4.0",
40
- "@adonisjs/tsconfig": "^1.4.0",
41
- "@release-it/conventional-changelog": "^10.0.0",
42
- "@swc/core": "1.10.7",
43
- "@types/chai": "^5.0.1",
44
- "@types/chai-subset": "^1.3.5",
38
+ "@adonisjs/eslint-config": "^2.1.0",
39
+ "@adonisjs/prettier-config": "^1.4.5",
40
+ "@adonisjs/tsconfig": "^1.4.1",
41
+ "@release-it/conventional-changelog": "^10.0.1",
42
+ "@swc/core": "1.13.1",
43
+ "@types/chai": "^5.2.2",
45
44
  "@types/find-cache-dir": "^5.0.2",
46
45
  "@types/ms": "^2.1.0",
47
- "@types/node": "^22.12.0",
46
+ "@types/node": "^24.0.15",
48
47
  "c8": "^10.1.3",
49
- "chai": "^5.1.2",
50
- "chai-subset": "^1.6.0",
48
+ "chai": "^5.2.1",
51
49
  "cross-env": "^7.0.3",
52
50
  "del-cli": "^6.0.0",
53
- "eslint": "^9.19.0",
54
- "glob": "^11.0.1",
55
- "prettier": "^3.4.2",
56
- "release-it": "^18.1.2",
51
+ "eslint": "^9.31.0",
52
+ "glob": "^11.0.3",
53
+ "prettier": "^3.6.2",
54
+ "release-it": "^19.0.4",
57
55
  "ts-node-maintained": "^10.9.5",
58
- "tsup": "^8.3.6",
59
- "typescript": "^5.7.3"
56
+ "tsup": "^8.5.0",
57
+ "typescript": "^5.8.3"
60
58
  },
61
59
  "dependencies": {
62
60
  "@japa/core": "^10.3.0",
63
61
  "@japa/errors-printer": "^4.1.2",
64
- "@poppinss/colors": "^4.1.4",
65
- "@poppinss/hooks": "^7.2.5",
62
+ "@poppinss/colors": "^4.1.5",
63
+ "@poppinss/hooks": "^7.2.6",
66
64
  "fast-glob": "^3.3.3",
67
- "find-cache-dir": "^5.0.0",
65
+ "find-cache-dir": "^6.0.0",
68
66
  "getopts": "^2.3.0",
69
67
  "ms": "^2.1.3",
70
68
  "serialize-error": "^12.0.0",