Skip to content

Add new instructions for vscode vitest workaround #1607

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions docs/ts/develop/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,35 @@ If using Vitest, follow these steps:
}
```

As of Vitest plugin version 0.5 ([issue](https://github.com/vitest-dev/vscode/issues/306)), environment configuration requires an updated approach. The following configuration is required to ensure proper functionality:

Update `settings.json` to include:

```jsonc
"vitest.nodeEnv": {
// generated with `encore daemon env | grep ENCORE_RUNTIME_LIB | cut -d'=' -f2`
"ENCORE_RUNTIME_LIB": "/opt/homebrew/Cellar/encore/1.44.5/libexec/runtimes/js/encore-runtime.node"
}
```

When running tests within VSCode, file-level parallel execution must be disabled. Update your `vite.config.ts` as follows:

```typescript
// File vite.config.ts
export default defineConfig({
resolve: {
alias: {
"~encore": path.resolve(__dirname, "./encore.gen"),
},
},
test: {
fileParallelism: false,
},
});
```

To improve the performance in CI, you can re-enable the parallel execution by overwriting the config in cli `encore test --fileParallelism=true`.

## Integration Testing Best Practices

Encore applications typically focus on integration tests rather than unit tests because:
Expand Down