Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/content/docs/limitations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ title: "Limitations"

<include>../limitations/builtin-apis/assertions.mdx</include>

<include>../limitations/builtin-apis/test-mocks.mdx</include>

<include>../limitations/builtin-apis/exit-status.mdx</include>

<include>../limitations/builtin-apis/process-memory.mdx</include>
Expand Down
1 change: 1 addition & 0 deletions docs/content/limitations/builtin-apis/test-mocks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Test mocks:** `mock.fn`, `mock.method`, `mock.restoreAll` and `mock.reset` compile, on the module's `mock` and on `t.mock`. `mock.method` mocks a function-valued field of a record, such as an object literal or an interface-typed object. Class instances, builtin objects, and object literals whose methods use `this` throw `SC2020`. Calls through the object record it as `this`, including calls of a method read off the object and called on its own, where Node records `undefined`. `object.method === mock` is `false`, because the field holds a wrapper of the mock. `mock.fn()` without an original, `mock.getter`, `mock.setter`, `mock.property`, `mock.module`, `mock.timers` and mock options throw `SC2020`.
2 changes: 1 addition & 1 deletion docs/src/generated/node-v24-compatibility-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"schemaVersion": 3,
"nodeVersion": "24.22.0",
"nodeCommit": "f14cd3aa7bf9ca8df2cc5b8bb14beb0f335b1d93",
"artifactVersion": "ae3ec89c0c8935ca6c07",
"artifactVersion": "d91d55ce5aa065b163bb",
"rowCount": 3880
}
22 changes: 11 additions & 11 deletions docs/src/generated/node-v24-compatibility.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,9 @@
"apiEntries": 117,
"static": {
"supported": 0,
"partial": 42,
"partial": 45,
"refused": 0,
"not-implemented": 75,
"not-implemented": 72,
"by-design": 0,
"unreviewed": 0,
"not-applicable": 0
Expand Down Expand Up @@ -65389,9 +65389,9 @@
"inherited": true
},
"static": {
"status": "not-implemented",
"detail": "No static compiler lowering is registered for this API yet.",
"verification": "registry-gap"
"status": "partial",
"detail": "Implemented for the documented scriptc module-loader subset.",
"verification": "test-backed"
}
},
{
Expand Down Expand Up @@ -65458,9 +65458,9 @@
"inherited": true
},
"static": {
"status": "not-implemented",
"detail": "No static compiler lowering is registered for this API yet.",
"verification": "registry-gap"
"status": "partial",
"detail": "Implemented for the documented scriptc module-loader subset.",
"verification": "test-backed"
}
},
{
Expand All @@ -65481,9 +65481,9 @@
"inherited": true
},
"static": {
"status": "not-implemented",
"detail": "No static compiler lowering is registered for this API yet.",
"verification": "registry-gap"
"status": "partial",
"detail": "Implemented for the documented scriptc module-loader subset.",
"verification": "test-backed"
}
},
{
Expand Down
61 changes: 41 additions & 20 deletions internal/compatibility/generated/node-v24-backlog.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"tierItemCount": 3472,
"tiers": {
"static": {
"audit-partial": 1061,
"verify-gap": 2284,
"audit-partial": 1064,
"verify-gap": 2281,
"replace-refusal": 40,
"classify": 2,
"implement": 85
Expand Down Expand Up @@ -66204,6 +66204,7 @@
"source": "compiler-feature:test.ctx.callCount",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
}
Expand Down Expand Up @@ -66232,6 +66233,7 @@
"source": "compiler-feature:test.ctx.mockImplementation",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
}
Expand Down Expand Up @@ -66260,6 +66262,7 @@
"source": "compiler-feature:test.ctx.mockImplementationOnce",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
}
Expand Down Expand Up @@ -66288,6 +66291,7 @@
"source": "compiler-feature:test.ctx.resetCalls",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
}
Expand Down Expand Up @@ -66316,6 +66320,7 @@
"source": "compiler-feature:test.ctx.restore",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
}
Expand Down Expand Up @@ -66344,6 +66349,7 @@
"source": "compiler-feature:test.calls",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
}
Expand Down Expand Up @@ -66668,12 +66674,17 @@
"priority": "high",
"tiers": {
"static": {
"status": "not-implemented",
"action": "verify-gap",
"verification": "registry-gap",
"confidence": "low",
"source": "compiler-unmatched:test",
"tests": []
"status": "partial",
"action": "audit-partial",
"verification": "test-backed",
"confidence": "high",
"source": "compiler-feature:test.mock.method",
"tests": [
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/corpus/5810-mock-method-records.ts",
"tests/corpus/5811-mock-tracker-restore.ts",
"tests/harness/node-test.test.ts"
]
}
}
},
Expand Down Expand Up @@ -66743,12 +66754,17 @@
"priority": "high",
"tiers": {
"static": {
"status": "not-implemented",
"action": "verify-gap",
"verification": "registry-gap",
"confidence": "low",
"source": "compiler-unmatched:test",
"tests": []
"status": "partial",
"action": "audit-partial",
"verification": "test-backed",
"confidence": "high",
"source": "compiler-feature:test.mock.reset",
"tests": [
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/corpus/5810-mock-method-records.ts",
"tests/corpus/5811-mock-tracker-restore.ts",
"tests/harness/node-test.test.ts"
]
}
}
},
Expand All @@ -66768,12 +66784,17 @@
"priority": "high",
"tiers": {
"static": {
"status": "not-implemented",
"action": "verify-gap",
"verification": "registry-gap",
"confidence": "low",
"source": "compiler-unmatched:test",
"tests": []
"status": "partial",
"action": "audit-partial",
"verification": "test-backed",
"confidence": "high",
"source": "compiler-feature:test.mock.restoreAll",
"tests": [
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/corpus/5810-mock-method-records.ts",
"tests/corpus/5811-mock-tracker-restore.ts",
"tests/harness/node-test.test.ts"
]
}
}
},
Expand Down
43 changes: 35 additions & 8 deletions internal/compatibility/generated/node-v24-internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,9 @@
"apiEntries": 117,
"static": {
"supported": 0,
"partial": 42,
"partial": 45,
"refused": 0,
"not-implemented": 75,
"not-implemented": 72,
"by-design": 0,
"unreviewed": 0,
"not-applicable": 0
Expand Down Expand Up @@ -90674,9 +90674,12 @@
"tests/corpus/1721-assert-throws-regex-class.ts",
"tests/corpus/2936-static-loose-equality.ts",
"tests/corpus/5515-assert-deep-strict-typed-messages.ts",
"tests/corpus/5810-mock-method-records.ts",
"tests/corpus/5811-mock-tracker-restore.ts",
"tests/fixtures/node-test/cases/ctx-hooks.ts",
"tests/fixtures/node-test/cases/ctx-plan.ts",
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/fixtures/node-test/cases/only-nested.ts",
"tests/fixtures/node-test/cases/suite-variants.ts",
"tests/fixtures/node-test/cases/todo-suites.ts",
Expand Down Expand Up @@ -91661,6 +91664,7 @@
"evidence": "compiler-feature:test.ctx.callCount",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
},
Expand Down Expand Up @@ -91688,6 +91692,7 @@
"evidence": "compiler-feature:test.ctx.mockImplementation",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
},
Expand Down Expand Up @@ -91715,6 +91720,7 @@
"evidence": "compiler-feature:test.ctx.mockImplementationOnce",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
},
Expand Down Expand Up @@ -91742,6 +91748,7 @@
"evidence": "compiler-feature:test.ctx.resetCalls",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
},
Expand Down Expand Up @@ -91769,6 +91776,7 @@
"evidence": "compiler-feature:test.ctx.restore",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
},
Expand Down Expand Up @@ -91796,6 +91804,7 @@
"evidence": "compiler-feature:test.calls",
"tests": [
"tests/fixtures/node-test/cases/mock-fn.ts",
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/harness/node-test.test.ts"
]
},
Expand Down Expand Up @@ -92122,8 +92131,14 @@
"inherited": true
},
"static": {
"status": "not-implemented",
"evidence": "compiler-unmatched:test"
"status": "partial",
"evidence": "compiler-feature:test.mock.method",
"tests": [
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/corpus/5810-mock-method-records.ts",
"tests/corpus/5811-mock-tracker-restore.ts",
"tests/harness/node-test.test.ts"
]
},
"anchorSource": "exact"
},
Expand Down Expand Up @@ -92191,8 +92206,14 @@
"inherited": true
},
"static": {
"status": "not-implemented",
"evidence": "compiler-unmatched:test"
"status": "partial",
"evidence": "compiler-feature:test.mock.reset",
"tests": [
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/corpus/5810-mock-method-records.ts",
"tests/corpus/5811-mock-tracker-restore.ts",
"tests/harness/node-test.test.ts"
]
},
"anchorSource": "exact"
},
Expand All @@ -92214,8 +92235,14 @@
"inherited": true
},
"static": {
"status": "not-implemented",
"evidence": "compiler-unmatched:test"
"status": "partial",
"evidence": "compiler-feature:test.mock.restoreAll",
"tests": [
"tests/fixtures/node-test/cases/mock-method.ts",
"tests/corpus/5810-mock-method-records.ts",
"tests/corpus/5811-mock-tracker-restore.ts",
"tests/harness/node-test.test.ts"
]
},
"anchorSource": "exact"
},
Expand Down
3 changes: 2 additions & 1 deletion internal/compatibility/static-support.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@
{ "chapter": "url", "signatures": ["Legacy `urlObject`", "`urlObject.auth`", "`urlObject.hash`", "`urlObject.host`", "`urlObject.hostname`", "`urlObject.href`", "`urlObject.path`", "`urlObject.pathname`", "`urlObject.port`", "`urlObject.protocol`", "`urlObject.query`", "`urlObject.search`", "`urlObject.slashes`"], "status": "partial", "evidence": ["tests/corpus/5221-url-parse-shapes.ts", "tests/corpus/5222-url-parse-hosts.ts", "tests/corpus/5223-url-parse-query.ts", "tests/corpus/5224-url-format-objects.ts", "tests/fixtures/node-types/url-legacy.ts"] },
{ "chapter": "test", "parent": "Class: `TestContext`", "symbols": ["context.diagnostic", "context.name"], "status": "partial", "evidence": ["tests/harness/node-test.test.ts"] },
{ "chapter": "test", "parent": "Class: `MockTracker`", "symbols": ["mock.fn"], "status": "partial", "evidence": ["tests/fixtures/node-test/cases/mock-fn.ts", "tests/harness/node-test.test.ts"] },
{ "chapter": "test", "parent": "Class: `MockFunctionContext`", "symbols": ["calls", "ctx.callCount", "ctx.mockImplementation", "ctx.mockImplementationOnce", "ctx.resetCalls", "ctx.restore"], "status": "partial", "evidence": ["tests/fixtures/node-test/cases/mock-fn.ts", "tests/harness/node-test.test.ts"] },
{ "chapter": "test", "parent": "Class: `MockTracker`", "symbols": ["mock.method", "mock.reset", "mock.restoreAll"], "status": "partial", "evidence": ["tests/fixtures/node-test/cases/mock-method.ts", "tests/corpus/5810-mock-method-records.ts", "tests/corpus/5811-mock-tracker-restore.ts", "tests/harness/node-test.test.ts"] },
{ "chapter": "test", "parent": "Class: `MockFunctionContext`", "symbols": ["calls", "ctx.callCount", "ctx.mockImplementation", "ctx.mockImplementationOnce", "ctx.resetCalls", "ctx.restore"], "status": "partial", "evidence": ["tests/fixtures/node-test/cases/mock-fn.ts", "tests/fixtures/node-test/cases/mock-method.ts", "tests/harness/node-test.test.ts"] },
{ "chapter": "test", "parent": "Class: `TestContext`", "symbols": ["context.before", "context.after", "context.beforeEach", "context.afterEach", "context.plan", "context.fullName"], "status": "partial", "evidence": ["tests/fixtures/node-test/cases/ctx-hooks.ts", "tests/fixtures/node-test/cases/ctx-plan.ts", "tests/harness/node-test.test.ts"] },
{ "chapter": "test", "symbols": ["describe.skip", "describe.todo", "describe.only", "suite.skip", "suite.todo", "suite.only", "it.skip", "it.todo", "it.only"], "status": "partial", "evidence": ["tests/fixtures/node-test/cases/suite-variants.ts", "tests/fixtures/node-test/cases/only-nested.ts", "tests/fixtures/node-test/cases/todo-suites.ts", "tests/harness/node-test.test.ts"] },
{ "chapter": "util", "signatures": ["`util.promisify(original)`"], "status": "partial", "evidence": ["tests/corpus/1473-promisify-execfile.ts", "tests/corpus/1573-promisify-execfile-env-spread.ts", "tests/corpus/2912-promisify-fs-readfile.ts", "tests/corpus/5625-promisify-exec.ts", "tests/corpus/5626-promisify-forms.ts", "tests/fixtures/node-types/promisify-fs.ts", "tests/corpus/5628-promisify-timers.ts", "tests/fixtures/node-types/promisify-timers.ts", "tests/corpus/5629-promisify-stream.ts", "tests/harness/project-config.test.ts"] },
Expand Down
31 changes: 25 additions & 6 deletions packages/compiler/ambient/scriptc-node-fallback.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3340,8 +3340,9 @@ declare module "node:test" {
function after(fn: HookFn): void;
function beforeEach(fn: HookFn): void;
function afterEach(fn: HookFn): void;
/* The mock function surface: mock.fn and t.mock.fn, with the calls log
* and the implementation controls on fn.mock. */
/* The mock function surface: mock.fn, mock.method and their t.mock
* twins, the tracker's restoreAll and reset, and the calls log and the
* implementation controls on fn.mock. */
interface MockFunctionCall<
F extends Function,
ReturnType = F extends (...args: any) => infer T ? T : unknown,
Expand All @@ -3361,17 +3362,35 @@ declare module "node:test" {
restore(): void;
}
type Mock<F extends Function> = F & { mock: MockFunctionContext<F> };
interface MockFunctionOptions {
times?: number;
}
type FunctionPropertyNames<T> = {
[K in keyof T]: T[K] extends Function ? K : never;
}[keyof T];
interface MockTracker {
fn<F extends Function = (...args: any[]) => undefined>(original?: F): Mock<F>;
fn<F extends Function = (...args: any[]) => undefined, Implementation extends Function = F>(
original?: F,
implementation?: Implementation,
): Mock<F | Implementation>;
method<MockedObject extends object>(
method<MockedObject extends object, MethodName extends FunctionPropertyNames<MockedObject>>(
object: MockedObject,
methodName: MethodName,
options?: MockFunctionOptions,
): MockedObject[MethodName] extends Function ? Mock<MockedObject[MethodName]> : never;
method<
MockedObject extends object,
MethodName extends FunctionPropertyNames<MockedObject>,
Implementation extends Function,
>(
object: MockedObject,
methodName: keyof MockedObject,
implementation?: Function,
): Mock<Function>;
methodName: MethodName,
implementation: Implementation,
options?: MockFunctionOptions,
): MockedObject[MethodName] extends Function
? Mock<MockedObject[MethodName] | Implementation>
: never;
reset(): void;
restoreAll(): void;
}
Expand Down
Loading
Loading