-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Environment options are not parsed from comments #1962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I just noticed that the JSDOM options are scoped under a |
We can just put options inside a key of current env: /**
* @jest-environment jsdom
* @jest-environment-options {"url": "https://example.com/"}
*/
// environmentOptions -> { jsdom: { url: string } } /**
* @jest-environment-options {"url": "https://example.com/"}
*/
// node is default environment. if config is used, will put into the one specified with config
// environmentOptions -> { node: { url: string } } All spec files have environment, so should not be a problem. |
I'm mostly thinking about Jest compatibility, and it doesn't use a |
|
The environment API may not be compatible, but we already document compatibility with the |
You wouldn't need to write |
Oh sorry, I think I misunderstood the purpose of the key. Is it just there so options other than those in the comments can be passed to the environment? Also can I still use that with a custom environment without having a 2D object? |
Yes, you can have multiple environments, so you need a key for each.
You would use it like this: // config
export default {
test: {
environmentOptions: {
custom: {} // your options
}
}
}
// or inside a spec file
/**
* @vitest-environment custom
* @vitest-environment-options { url: "http://example.com" }
*/ |
Describe the bug
Vitest supports parsing
@{vitest,jest}-environment
comments to set an environment, but it should also support@{vitest,jest}-environment-options
comments for compatibility with Jest.Reproduction
index.test.js
vite.config.js
Expected result from Jest
Actual result from Vitest
System Info
System: OS: macOS 12.5.1 CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz Memory: 43.91 MB / 8.00 GB Shell: 3.5.1 - /usr/local/bin/fish Binaries: Node: 18.8.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.19.1 - /usr/local/bin/npm Watchman: 2022.08.29.00 - /usr/local/bin/watchman npmPackages: vitest: ^0.18.0 => 0.18.1
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: