Skip to content

Commit 60debac

Browse files
author
Taras Mankovski
committed
Revert "Add expect.assertions() support for Node.js tests"
This reverts commit 12374ad.
1 parent d1e6d99 commit 60debac

10 files changed

Lines changed: 5 additions & 108 deletions

File tree

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

bdd/bdd.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export interface TestPrimitives {
1717
only: (name: string, fn: () => void | Promise<void>) => void;
1818
};
1919
afterAll: (fn: () => void | Promise<void>) => void;
20-
/** Optional hook called after each test for assertion state cleanup */
21-
afterEachTest?: () => void;
2220
}
2321

2422
/**
@@ -44,8 +42,7 @@ export interface BDD {
4442
* This allows the BDD module to work with different test runners.
4543
*/
4644
export function createBDD(primitives: TestPrimitives): BDD {
47-
const { describe: $describe, it: $it, afterAll: $afterAll, afterEachTest } =
48-
primitives;
45+
const { describe: $describe, it: $it, afterAll: $afterAll } = primitives;
4946

5047
let current: TestAdapter | undefined;
5148

@@ -94,7 +91,6 @@ export function createBDD(primitives: TestPrimitives): BDD {
9491
}
9592
$it(desc, async () => {
9693
const result = await adapter.runTest(body);
97-
afterEachTest?.();
9894
if (!result.ok) {
9995
throw result.error;
10096
}
@@ -110,7 +106,6 @@ export function createBDD(primitives: TestPrimitives): BDD {
110106
const adapter = current!;
111107
$it.only(desc, async () => {
112108
const result = await adapter.runTest(body);
113-
afterEachTest?.();
114109
if (!result.ok) {
115110
throw result.error;
116111
}

bdd/mod.node.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,10 @@
11
import { after, describe as $describe, it as $it } from "node:test";
2-
import { getAssertionState } from "@std/internal/assertion-state";
32
import { createBDD } from "./bdd.ts";
43

5-
/**
6-
* Checks and resets the assertion state after each test.
7-
* This ensures expect.assertions() works correctly with Node's test runner.
8-
*/
9-
function checkAndResetAssertions(): void {
10-
const state = getAssertionState();
11-
12-
// Check if expect.hasAssertions() was used but no assertion was triggered
13-
if (state.checkAssertionErrorState()) {
14-
state.resetAssertionState();
15-
throw new Error(
16-
"Expected at least one assertion to be called but received none",
17-
);
18-
}
19-
20-
// Check if expect.assertions(n) count was not satisfied
21-
if (state.checkAssertionCountSatisfied()) {
22-
const expected = state.assertionCount;
23-
const actual = state.assertionTriggeredCount;
24-
state.resetAssertionState();
25-
throw new Error(
26-
`Expected ${expected} assertions to be called but received ${actual}`,
27-
);
28-
}
29-
30-
// Reset for next test
31-
state.resetAssertionState();
32-
}
33-
344
const bdd = createBDD({
355
describe: $describe,
366
it: $it,
377
afterAll: after,
38-
afterEachTest: checkAndResetAssertions,
398
});
409

4110
export const { describe, it, beforeAll, beforeEach } = bdd;

context-api/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
"type": "module",
55
"license": "MIT",
66
"exports": "./mod.ts",
7-
"scripts": {
8-
"test": "node --experimental-strip-types --test *.test.ts"
9-
},
107
"dependencies": {
11-
"effection": "^3",
12-
"@effectionx/bdd": "workspace:*"
8+
"effection": "^3"
139
}
1410
}

deno.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"nodeModulesDir": "none",
33
"imports": {
44
"effection": "npm:effection@^3",
5-
"@std/expect": "jsr:@std/expect@^1",
65
"@deno/dnt": "jsr:@deno/dnt@0.42.3",
76
"@std/path": "jsr:@std/path@^1",
87
"zod": "npm:zod@3.23.8",

fx/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
"type": "module",
55
"license": "MIT",
66
"exports": "./mod.ts",
7-
"scripts": {
8-
"test": "node --experimental-strip-types --test *.test.ts"
9-
},
107
"dependencies": {
11-
"effection": "^3",
12-
"@effectionx/bdd": "workspace:*"
8+
"effection": "^3"
139
}
1410
}

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"test": "pnpm -r --if-present test"
88
},
99
"dependencies": {
10-
"@std/expect": "npm:@jsr/std__expect@^1",
11-
"@std/internal": "npm:@jsr/std__internal@^1",
1210
"effection": "^3"
1311
},
1412
"volta": {

pnpm-lock.yaml

Lines changed: 0 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

signals/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
"type": "module",
55
"license": "MIT",
66
"exports": "./mod.ts",
7-
"scripts": {
8-
"test": "node --experimental-strip-types --test *.test.ts"
9-
},
107
"dependencies": {
118
"effection": "^3",
12-
"immutable": "^5",
13-
"@effectionx/bdd": "workspace:*"
9+
"immutable": "^5"
1410
}
1511
}

timebox/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
"type": "module",
55
"license": "MIT",
66
"exports": "./mod.ts",
7-
"scripts": {
8-
"test": "node --experimental-strip-types --test *.test.ts"
9-
},
107
"dependencies": {
11-
"effection": "^3",
12-
"@effectionx/bdd": "workspace:*"
8+
"effection": "^3"
139
}
1410
}

0 commit comments

Comments
 (0)