Skip to content

Commit

Permalink
feat(docs): Show VITEST_WORKER_ID-based port assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
toBeOfUse committed Nov 30, 2024
1 parent a82f5be commit b86b8c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/docs/guides/developer-guide/testing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ All that's left is to run your tests to find out whether your code behaves as ex

:::caution
**Note:** When using **Vitest** with multiple test suites (multiple `.e2e-spec.ts` files), it will attempt to run them in parallel. If all the test servers are running
on the same port (the default in the `testConfig` is `3050`), then this will cause a port conflict. To avoid this, you can manually set a unique port for each test suite. Be aware that `mergeConfig` is used here:
on the same port (the default in the `testConfig` is `3050`), then this will cause a port conflict. To avoid this, you can use the `VITEST_WORKER_ID` environment variable to set a unique port for each test suite. Be aware that `mergeConfig` is used here:

```ts title="src/plugins/my-plugin/e2e/my-plugin.e2e-spec.ts"
import { createTestEnvironment, testConfig } from '@vendure/testing';
Expand All @@ -208,7 +208,7 @@ describe('my plugin', () => {
const {server, adminClient, shopClient} = createTestEnvironment(mergeConfig(testConfig, {
// highlight-start
apiOptions: {
port: 3051,
port: 3050 + Number(process.env.VITEST_WORKER_ID),
},
// highlight-end
plugins: [MyPlugin],
Expand Down

0 comments on commit b86b8c2

Please sign in to comment.