From b44b65a90645a150c166c43a0e493f470ac2791f Mon Sep 17 00:00:00 2001 From: Alexander Davydov Date: Fri, 20 Mar 2026 12:59:14 +0300 Subject: [PATCH] Tests: reload jiti in loader regression test --- .../loader.git-path-regression.test.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/plugins/loader.git-path-regression.test.ts b/src/plugins/loader.git-path-regression.test.ts index f1a200730b4..e66771ab714 100644 --- a/src/plugins/loader.git-path-regression.test.ts +++ b/src/plugins/loader.git-path-regression.test.ts @@ -1,18 +1,30 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import { afterEach, describe, expect, it } from "vitest"; -import { __testing } from "./loader.js"; +import { afterEach, describe, expect, it, vi } from "vitest"; type CreateJiti = typeof import("jiti").createJiti; +type LoaderTesting = (typeof import("./loader.js"))["__testing"]; let createJitiPromise: Promise | undefined; +let loaderTestingPromise: Promise | undefined; async function getCreateJiti() { createJitiPromise ??= import("jiti").then(({ createJiti }) => createJiti); return createJitiPromise; } +async function getLoaderTesting() { + loaderTestingPromise ??= (async () => { + vi.resetModules(); + vi.doUnmock("jiti"); + vi.doUnmock("./loader.js"); + const { __testing } = await import("./loader.js"); + return __testing; + })(); + return loaderTestingPromise; +} + const tempRoots: string[] = []; function makeTempDir() { @@ -29,10 +41,13 @@ afterEach(() => { for (const dir of tempRoots.splice(0)) { fs.rmSync(dir, { recursive: true, force: true }); } + createJitiPromise = undefined; + loaderTestingPromise = undefined; }); describe("plugin loader git path regression", () => { it("loads git-style package extension entries when they import plugin-sdk channel-runtime (#49806)", async () => { + const __testing = await getLoaderTesting(); const copiedExtensionRoot = path.join(makeTempDir(), "extensions", "imessage"); const copiedSourceDir = path.join(copiedExtensionRoot, "src"); const copiedPluginSdkDir = path.join(copiedExtensionRoot, "plugin-sdk");