Skip to content

Commit cd39881

Browse files
committed
punctuation
1 parent f41763d commit cd39881

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/content/docs/workers/testing/vitest-integration/isolation-and-concurrency.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The Workers Vitest pool works by running code inside a Cloudflare Worker that Vi
6363

6464
Using Vitest Pool Workers may cause your Worker to behave differently when deployed than during testing as the `nodejs_compat` flag is enabled by default. This means that Node.js-specific APIs and modules are available when running your tests. However, Cloudflare Workers do not support these Node.js APIs in the production environment unless you specify this flag in your Worker configuration.
6565

66-
If you do not have a `nodejs_compat` or `nodejs_compat_v2` flag in your configuration and you import a Node.js module in your Worker code, your tests may pass, but you will find that you will not be able to deploy this Worker as the upload call (either via the REST API or via Wrangler) will throw an error.
66+
If you do not have a `nodejs_compat` or `nodejs_compat_v2` flag in your configuration and you import a Node.js module in your Worker code, your tests may pass, but you will find that you will not be able to deploy this Worker, as the upload call (either via the REST API or via Wrangler) will throw an error.
6767

6868
However, if you use Node.js globals that are not supported by the runtime, your Worker upload will be successful, but you may see errors in production code. Let's create a contrived example to illustrate the issue.
6969

@@ -87,7 +87,7 @@ export default {
8787
} satisfies ExportedHandler<Env>;
8888
```
8989

90-
The test simple assertion that the Worker managed to use `process`.
90+
The test is a simple assertion that the Worker managed to use `process`.
9191

9292
```typescript
9393
it('responds with "test"', async () => {
@@ -108,4 +108,6 @@ Now, if we run `npm run test`, we see that the tests will _pass_:
108108

109109
And we can run `wrangler dev` and `wrangler deploy` without issues. It _looks like_ our code is fine. However, this code will fail in production as `process` is not available in the Workerd runtime.
110110

111+
To fix the issue, we either need to avoid using Node.js APIs, or add the `nodejs_compat` flag to our Wrangler configuration.
112+
111113
:::

0 commit comments

Comments
 (0)