-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support jest plugins that use jest
globals (jest is not defined
)
#2667
Comments
I also tried setting the import {defineConfig} from 'vitest/config';
export default defineConfig({
test: {
globals: true,
setupFiles: [
'./vitest.setup.js',
'jest-webextension-mock',
],
},
}); // vitest.setup.js
import {vi} from 'vitest';
global.jest = vi; This was also suggested by a member elsewhere: #1193 (comment) |
You can add jest global before importing setup file: globalThis.jest = vi
import "jest-webextension-mock" |
That |
Try before commenting, please. Import statements are not hoisted in Vitest to support module mocking. If you are too afraid to break something, you can use |
Can be documented, yes. We will never add |
How come my previous example didn't work? #2667 (comment) I assume setupFiles are meant to create globals among other things |
Yes. They are running in parallel, not sequential, so it's possible mock resolved before globals were setup. |
Since there's
|
No plans to support requireActual. |
You can use |
Clear and concise description of the problem
I'm trying to use https://github.com/clarkbw/jest-webextension-mock in Vitest but it fails on load even if I use
globals: true
because the package expects thejest
globalSuggested solution
Add
jest
global in dependencies as a tentative compatibility layer, optionally.Alternative
Add explicit vitest support to every single package I try using 😰 with productivity going 📉
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: