-
Notifications
You must be signed in to change notification settings - Fork 264
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
Not able to get working with Vite #1046
Comments
I'm not fully clear on what exactly you are trying to do. What do you mean by "working with Vite"? If you want to run your tests in a browser with Vite, you will likely need to use something like Mocha, that is environment agnostic. I'm not clear on how Jest + Vite fit together here. Test Utils itself works fine in a browser. I might need more information on your setup, expected result, etc. |
Basically, Vite specific methods ( After a lot of trial and error, I have managed to get Vite + Jest + Vue Test Utils to work together, albeit a lot of hacks has been used. I understand it's not quite the issue of Vue Test Utils, so I'll close this issue. For anyone searching this issue, the way I solved the Base Components issue (due to globEager not working), is to just manually import them all and then pass to Here how my // ===
// Configure Vue instance in Vue Test Utils
// ===
import { config } from '@vue/test-utils';
import { i18n } from '@/plugins/i18n';
import icons from '@/plugins/heroicons';
// Need to manually import all the components, due to inability to use `plugins` API, due to `import.meta.globEager` not working
import BaseBadge from '@/components/base_components/BaseBadge';
import BaseLoader from '@/components/base_components/BaseLoader';
...
config.renderStubDefaultSlot = true;
config.global = {
directives: {
ScrollTo: true,
Tippy: true,
Touch: true,
TouchOptions: true,
TouchClass: true,
RouterView: true,
},
plugins: [icons, i18n],
mocks: {
$toasts: { error: jest.fn(), base: jest.fn(), success: jest.fn() },
},
components: {
BaseBadge,
BaseLoader,
...
},
}; |
Good to see you found a solution. Out of curiosity, why do you need |
@lmiller1990 I just want to be able to pass my custom plugin to the Vue app, instead of having to manually import components. I am looking to see if I can preload all base components without using |
I am having trouble getting the tests to work with Vite, specifically due to the
import
object that is provided. One example is loading in global components using Vue Test Utils config:hitting an issue with
globEager
when trying to provide plugins to configHere my plugin:
I am trying to pass this plugin in my setup script for Jest using Vue Test Utils:
But I get an error
process.globEager is not a function
The text was updated successfully, but these errors were encountered: