-
Notifications
You must be signed in to change notification settings - Fork 31
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
Vitest testing #294
Comments
I agree that it would be nice to support compatible testing-libraries as much as possible, but in this case this could be a bit too much. The only jest-function we actually use is Alternatively, it should be possible to inject a simple |
Easy to fix: import { vi } from "vitest";
globalThis.jest = vi;
... = await import("@googlemaps/jest-mocks"); (Do not use package @anshulsanghi/googlemaps-vitest-mocks it's a poor solution: no need to fork |
Reply to a now-deleted commentnot sure what `setup-env` is... Is that a file you specified to vitest via the setupFiles option? Also you can `@ts-ignore` those type-errors (or provide the file as js), we know they aren't 100% compatible, but it should be enough for our use-case.According to the docs here: https://vitest.dev/config/#setupfiles, it should also be |
This is what ended up working for us:
vi.stubGlobal('jest', vi) At that point you can actually just proceed to import and use the module as advertised in the original docs Ie import { initialize } from "@googlemaps/jest-mocks";
beforeEach(() => {
initialize();
}); |
My team and I have used your
Jest Mocks
when we started doing unit tests withJest
. But we are switching over to useVite
andVitest
which has very similar apis. But we cannot usejest
andvitest
together.Describe the solution you'd like
It would be nice to have a package like this targeting the
vitest
testing library (I think just changing overjest.whatever
tovi.whater
might be enough?)Describe alternatives you've considered
I thought about forking this repo for Vitest, but didn't want to maintain such a thing.
Additional context
N/A
The text was updated successfully, but these errors were encountered: