How Do I Setup Custom Test Environment After Configuring It? #9737
Answered
by
aniruddhaadak80
Android789515
asked this question in
Q&A
-
|
The docs show how to create the boilerplate for the config but all it says afterword is a comment inside the setup method that says custom setup. I don't know what to setup in there. For context, I'm trying to create a custom environment for Electron, so Possible related: #8694 |
Beta Was this translation helpful? Give feedback.
Answered by
aniruddhaadak80
Mar 14, 2026
Replies: 1 comment
-
|
@Android789515 A custom environment usually requires extends accessing the setup. export default {
name: ''my-electron-env'',
setup(global) {
// Inject mocks
global.window = { ... };
return {
teardown() { ... }
}
}
}Then in test: {
environment: ''./libs/my-env/index.ts''
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Android789515
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Android789515 A custom environment usually requires extends accessing the setup.
In
libs/my-env/index.ts:Then in
vitest.config.ts: