Skip to content

Commit 2309860

Browse files
Update src/content/docs/workers/testing/vitest-integration/known-issues.mdx
Co-authored-by: ToriLindsay <[email protected]>
1 parent 155837f commit 2309860

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/content/docs/workers/testing/vitest-integration/known-issues.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ You can find an example in the [Recipes](/workers/testing/vitest-integration/rec
6464

6565
### Importing modules from global setup file
6666

67-
While Vitest is instructed to resolve packages for the `workerd` runtime, it runs your global setup file in the NodeJS environment. This is why you might encounter issue importing pacakges like [Postgres.js](https://github.com/cloudflare/workers-sdk/issues/6465) that export non-node version for `workerd`. To get around this issue, you can create a wrapper that uses Vite's SSR module loader to import your global setup file under the correct conditions. Then, adjust your Vitest configuration to point to this wrapper. For example:
67+
Although Vitest is set up to resolve packages for the `workerd` runtime, it runs your global setup file in the Node.js environment. This can cause issues when importing packages like [Postgres.js](https://github.com/cloudflare/workers-sdk/issues/6465), which exports a non-Node version for `workerd`.
68+
To work around this, you can create a wrapper that uses Vite's SSR module loader to import the global setup file under the correct conditions. Then, adjust your Vitest configuration to point to this wrapper. For example:
6869

6970
```ts
7071
// File: global-setup-wrapper.ts

0 commit comments

Comments
 (0)