Skip to content
Open
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
4 changes: 2 additions & 2 deletions docs/guide/essentials/unit-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
Expand All @@ -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<Account>('local:account');

Expand Down
8 changes: 8 additions & 0 deletions packages/wxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@
"types": "./dist/testing/index.d.ts",
"default": "./dist/testing/index.mjs"
},
"./testing/fake-browser": {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optionally we could remove the import above so no one can import wxt/testing directly 🤔

"types": "./dist/testing/fake-browser.d.ts",
"default": "./dist/testing/fake-browser.mjs"
},
"./testing/wxt-vitest-plugin": {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted to follow the same testing convention of wxt/testing/wxt-vitest-plugin

we can definitely change this to wxt/wxt-vitest-plugin if ya'll like that better 🤔

"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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/wxt/src/testing/wxt-vitest-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
Expand Down
Loading