perf(test): reduce module reload overhead in key suites

This commit is contained in:
Peter Steinberger
2026-02-13 15:45:08 +00:00
parent 4337fa2096
commit 41f2f359a5
12 changed files with 114 additions and 116 deletions

View File

@@ -1,4 +1,5 @@
import { describe, expect, it, vi, beforeEach } from "vitest";
import { resolveBrowserExecutableForPlatform } from "./chrome.executables.js";
vi.mock("node:child_process", () => ({
execFileSync: vi.fn(),
@@ -17,11 +18,10 @@ import * as fs from "node:fs";
describe("browser default executable detection", () => {
beforeEach(() => {
vi.resetModules();
vi.clearAllMocks();
});
it("prefers default Chromium browser on macOS", async () => {
it("prefers default Chromium browser on macOS", () => {
vi.mocked(execFileSync).mockImplementation((cmd, args) => {
const argsStr = Array.isArray(args) ? args.join(" ") : "";
if (cmd === "/usr/bin/plutil" && argsStr.includes("LSHandlers")) {
@@ -45,7 +45,6 @@ describe("browser default executable detection", () => {
return value.includes("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
});
const { resolveBrowserExecutableForPlatform } = await import("./chrome.executables.js");
const exe = resolveBrowserExecutableForPlatform(
{} as Parameters<typeof resolveBrowserExecutableForPlatform>[0],
"darwin",
@@ -55,7 +54,7 @@ describe("browser default executable detection", () => {
expect(exe?.kind).toBe("chrome");
});
it("falls back when default browser is non-Chromium on macOS", async () => {
it("falls back when default browser is non-Chromium on macOS", () => {
vi.mocked(execFileSync).mockImplementation((cmd, args) => {
const argsStr = Array.isArray(args) ? args.join(" ") : "";
if (cmd === "/usr/bin/plutil" && argsStr.includes("LSHandlers")) {
@@ -73,7 +72,6 @@ describe("browser default executable detection", () => {
return value.includes("Google Chrome.app/Contents/MacOS/Google Chrome");
});
const { resolveBrowserExecutableForPlatform } = await import("./chrome.executables.js");
const exe = resolveBrowserExecutableForPlatform(
{} as Parameters<typeof resolveBrowserExecutableForPlatform>[0],
"darwin",