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: 1 addition & 1 deletion types/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"https://bun.com"
],
"dependencies": {
"bun-types": "1.3.8"
"bun-types": "1.3.9"
},
"devDependencies": {
"@types/bun": "workspace:."
Expand Down
12 changes: 12 additions & 0 deletions types/node/node-tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
todo,
} from "node:test";
import { dot, junit, lcov, spec, tap, TestEvent } from "node:test/reporters";
import { URL } from "node:url";

// top-level export
test satisfies typeof import("node:test");
Expand Down Expand Up @@ -795,6 +796,7 @@ test("mocks a setter", (t) => {
});

test("mocks a module", (t) => {
// module specifier as a string
// $ExpectType MockModuleContext
const mock = t.mock.module("node:readline", {
namedExports: {
Expand All @@ -811,6 +813,16 @@ test("mocks a module", (t) => {
});
// $ExpectType void
mock.restore();

// module specifier as a URL
// $ExpectType MockModuleContext
t.mock.module(new URL("someUrl"), {
namedExports: {
fn() {
return 42;
},
},
});
});

test("mocks a property", (t) => {
Expand Down
3 changes: 2 additions & 1 deletion types/node/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ declare module "node:test" {
import { AssertMethodNames } from "node:assert";
import { Readable, ReadableEventMap } from "node:stream";
import { TestEvent } from "node:test/reporters";
import { URL } from "node:url";
import TestFn = test.TestFn;
import TestOptions = test.TestOptions;
/**
Expand Down Expand Up @@ -1692,7 +1693,7 @@ declare module "node:test" {
* @param specifier A string identifying the module to mock.
* @param options Optional configuration options for the mock module.
*/
module(specifier: string, options?: MockModuleOptions): MockModuleContext;
module(specifier: string | URL, options?: MockModuleOptions): MockModuleContext;
/**
* Creates a mock for a property value on an object. This allows you to track and control access to a specific property,
* including how many times it is read (getter) or written (setter), and to restore the original value after mocking.
Expand Down
3 changes: 2 additions & 1 deletion types/node/v22/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
declare module "node:test" {
import { AssertMethodNames } from "node:assert";
import { Readable } from "node:stream";
import { URL } from "node:url";
import TestFn = test.TestFn;
import TestOptions = test.TestOptions;
/**
Expand Down Expand Up @@ -1638,7 +1639,7 @@ declare module "node:test" {
* @param specifier A string identifying the module to mock.
* @param options Optional configuration options for the mock module.
*/
module(specifier: string, options?: MockModuleOptions): MockModuleContext;
module(specifier: string | URL, options?: MockModuleOptions): MockModuleContext;
/**
* This function restores the default behavior of all mocks that were previously
* created by this `MockTracker` and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used, but the `MockTracker` instance can no longer be
Expand Down
12 changes: 12 additions & 0 deletions types/node/v22/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
todo,
} from "node:test";
import { dot, junit, lcov, spec, tap, TestEvent } from "node:test/reporters";
import { URL } from "node:url";

// top-level export
test satisfies typeof import("node:test");
Expand Down Expand Up @@ -791,6 +792,7 @@ test("mocks a setter", (t) => {
});

test("mocks a module", (t) => {
// module specifier as a string
// $ExpectType MockModuleContext
const mock = t.mock.module("node:readline", {
namedExports: {
Expand All @@ -807,6 +809,16 @@ test("mocks a module", (t) => {
});
// $ExpectType void
mock.restore();

// module specifier as a URL
// $ExpectType MockModuleContext
t.mock.module(new URL("someUrl"), {
namedExports: {
fn() {
return 42;
},
},
});
});

// @ts-expect-error
Expand Down
3 changes: 2 additions & 1 deletion types/node/v24/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
declare module "node:test" {
import { AssertMethodNames } from "node:assert";
import { Readable } from "node:stream";
import { URL } from "node:url";
import TestFn = test.TestFn;
import TestOptions = test.TestOptions;
/**
Expand Down Expand Up @@ -1711,7 +1712,7 @@ declare module "node:test" {
* @param specifier A string identifying the module to mock.
* @param options Optional configuration options for the mock module.
*/
module(specifier: string, options?: MockModuleOptions): MockModuleContext;
module(specifier: string | URL, options?: MockModuleOptions): MockModuleContext;
/**
* Creates a mock for a property value on an object. This allows you to track and control access to a specific property,
* including how many times it is read (getter) or written (setter), and to restore the original value after mocking.
Expand Down
12 changes: 12 additions & 0 deletions types/node/v24/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
todo,
} from "node:test";
import { dot, junit, lcov, spec, tap, TestEvent } from "node:test/reporters";
import { URL } from "node:url";

// top-level export
test satisfies typeof import("node:test");
Expand Down Expand Up @@ -795,6 +796,7 @@ test("mocks a setter", (t) => {
});

test("mocks a module", (t) => {
// module specifier as a string
// $ExpectType MockModuleContext
const mock = t.mock.module("node:readline", {
namedExports: {
Expand All @@ -811,6 +813,16 @@ test("mocks a module", (t) => {
});
// $ExpectType void
mock.restore();

// module specifier as a URL
// $ExpectType MockModuleContext
t.mock.module(new URL("someUrl"), {
namedExports: {
fn() {
return 42;
},
},
});
});

test("mocks a property", (t) => {
Expand Down