From 05ed927a3b065a1fb8486bca966ea2997ff48218 Mon Sep 17 00:00:00 2001 From: marcellino ornelas <35247622+marcellino-ornelas@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:38:57 -0700 Subject: [PATCH 1/5] Add specific imports to testing sub files --- packages/wxt/package.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/wxt/package.json b/packages/wxt/package.json index e106b275a..9c5f6806b 100644 --- a/packages/wxt/package.json +++ b/packages/wxt/package.json @@ -183,6 +183,14 @@ "types": "./dist/testing/index.d.ts", "default": "./dist/testing/index.mjs" }, + "./testing/fake-browser": { + "types": "./dist/testing/fake-browser.d.ts", + "default": "./dist/testing/fake-browser.mjs" + }, + "./testing/wxt-vitest-plugin": { + "types": "./dist/testing/wxt-vitest-plugin.d.ts", + "default": "./dist/testing/wxt-vitest-plugin.mjs" + }, "./vite-builder-env": { "types": "./dist/vite-builder-env.d.ts" }, From 258c0666375f61ba9a930cc68ea89d7accd92452 Mon Sep 17 00:00:00 2001 From: marcellino ornelas <35247622+marcellino-ornelas@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:41:59 -0700 Subject: [PATCH 2/5] Update import in extensionApiMock.ts --- packages/wxt/src/core/builders/vite/plugins/extensionApiMock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wxt/src/core/builders/vite/plugins/extensionApiMock.ts b/packages/wxt/src/core/builders/vite/plugins/extensionApiMock.ts index 0e2b18f3a..ee46f4ef1 100644 --- a/packages/wxt/src/core/builders/vite/plugins/extensionApiMock.ts +++ b/packages/wxt/src/core/builders/vite/plugins/extensionApiMock.ts @@ -43,7 +43,7 @@ export function extensionApiMock(config: ResolvedConfig): vite.PluginOption { const setupTemplate = ` import { vi } from 'vitest'; - import { fakeBrowser } from 'wxt/testing'; + import { fakeBrowser } from 'wxt/testing/fake-browser'; vi.stubGlobal("chrome", fakeBrowser); vi.stubGlobal("browser", fakeBrowser); From 927c59b819501b89daf9a754a215a22236e524b1 Mon Sep 17 00:00:00 2001 From: marcellino ornelas <35247622+marcellino-ornelas@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:42:56 -0700 Subject: [PATCH 3/5] Update docs in wxt-vitest-plugin.ts --- packages/wxt/src/testing/wxt-vitest-plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wxt/src/testing/wxt-vitest-plugin.ts b/packages/wxt/src/testing/wxt-vitest-plugin.ts index cd59f338a..b29fa03da 100644 --- a/packages/wxt/src/testing/wxt-vitest-plugin.ts +++ b/packages/wxt/src/testing/wxt-vitest-plugin.ts @@ -16,7 +16,7 @@ import { registerWxt, wxt } from '../core/wxt'; * ```ts * // vitest.config.ts * import { defineConfig } from 'vitest/config'; - * import { WxtVitest } from 'wxt/testing'; + * import { WxtVitest } from 'wxt/testing/wxt-vitest-plugin'; * * export default defineConfig({ * plugins: [WxtVitest()], From a3db7a9ecccac5fd564d13b8e23bbe2e93f50336 Mon Sep 17 00:00:00 2001 From: marcellino ornelas <35247622+marcellino-ornelas@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:43:55 -0700 Subject: [PATCH 4/5] Update unit-testing.md --- docs/guide/essentials/unit-testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/essentials/unit-testing.md b/docs/guide/essentials/unit-testing.md index 9e12c8bb9..c7f7ec446 100644 --- a/docs/guide/essentials/unit-testing.md +++ b/docs/guide/essentials/unit-testing.md @@ -9,7 +9,7 @@ WXT provides first class support for Vitest for unit testing: ```ts // vitest.config.ts import { defineConfig } from 'vitest/config'; -import { WxtVitest } from 'wxt/testing'; +import { WxtVitest } from 'wxt/testing/wxt-vitest-plugin'; export default defineConfig({ plugins: [WxtVitest()], From 397492c7959fa41c278c4794106aa012df414766 Mon Sep 17 00:00:00 2001 From: marcellino ornelas <35247622+marcellino-ornelas@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:44:27 -0700 Subject: [PATCH 5/5] Update unit test doc --- docs/guide/essentials/unit-testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/essentials/unit-testing.md b/docs/guide/essentials/unit-testing.md index c7f7ec446..402f6be14 100644 --- a/docs/guide/essentials/unit-testing.md +++ b/docs/guide/essentials/unit-testing.md @@ -36,7 +36,7 @@ This example demonstrates that you don't have to mock `browser.storage` (used by ```ts import { describe, it, expect } from 'vitest'; -import { fakeBrowser } from 'wxt/testing'; +import { fakeBrowser } from 'wxt/testing/fake-browser'; const accountStorage = storage.defineItem('local:account');