diff --git a/types/bun/package.json b/types/bun/package.json index 97f3665e91ae0e..407f9072c1f4e2 100644 --- a/types/bun/package.json +++ b/types/bun/package.json @@ -6,7 +6,7 @@ "https://bun.com" ], "dependencies": { - "bun-types": "1.3.8" + "bun-types": "1.3.9" }, "devDependencies": { "@types/bun": "workspace:." diff --git a/types/node/node-tests/test.ts b/types/node/node-tests/test.ts index a63d8c64e9c294..4b5014139e2e87 100644 --- a/types/node/node-tests/test.ts +++ b/types/node/node-tests/test.ts @@ -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"); @@ -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: { @@ -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) => { diff --git a/types/node/test.d.ts b/types/node/test.d.ts index 12d1af38a1d9a6..a3d3b682055ee1 100644 --- a/types/node/test.d.ts +++ b/types/node/test.d.ts @@ -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; /** @@ -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. diff --git a/types/node/v22/test.d.ts b/types/node/v22/test.d.ts index 1c173f6a26e0aa..1e9613a84c7796 100644 --- a/types/node/v22/test.d.ts +++ b/types/node/v22/test.d.ts @@ -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; /** @@ -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 diff --git a/types/node/v22/test/test.ts b/types/node/v22/test/test.ts index e7f2faa70870eb..5dcfae3157a9e9 100644 --- a/types/node/v22/test/test.ts +++ b/types/node/v22/test/test.ts @@ -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"); @@ -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: { @@ -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 diff --git a/types/node/v24/test.d.ts b/types/node/v24/test.d.ts index e1f103d776f3f9..1b237deb705116 100644 --- a/types/node/v24/test.d.ts +++ b/types/node/v24/test.d.ts @@ -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; /** @@ -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. diff --git a/types/node/v24/test/test.ts b/types/node/v24/test/test.ts index 8a9db2c385d016..2be5e5274c7437 100644 --- a/types/node/v24/test/test.ts +++ b/types/node/v24/test/test.ts @@ -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"); @@ -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: { @@ -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) => {