-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Request] Add compatibility with other libraries #44
Comments
Hi there @dospunk, Thank you very much for the issue!
That is the plan. I agree, I took some shortcuts, because I didn't have anything other than jest at the time. I would very much like to expand the support for other test runners
Isn't vitest compatible with jest by default? I thought that was the case, but I never tested it. I will try to set aside some time to look into it, unless you would like to help me out. At the very least, by describing your specific case |
@trurl-master Vitest is "compatible" with jest in that it defines most of its APIs to be compatible, but it doesn't support things like accessing the A quick and dirty solution might be to have a "testingLib" variable somewhere defined like const testingLib = jest ?? vi but that runs into issues quickly when you consider scaling to include other frameworks that may not use the same APIs as Jest, or if Vitest and Jest's APIs start to diverge. The best solution I've come up with is to switch to a library-agnostic mock system like sinon (I know both Jest and Vitest use their fake-timers library). The downside here is losing that easy Jest mock compatibility. |
Hey @dospunk! I just released a beta version that should improve the situation. For Thank you for bringing this to my attention in any case! |
It works! Having to set toFake on vi.useFakeTimers every time is a bit clunky but just a limitation of the library I suppose. The only issue I had is having to change |
@trurl-master I recreated your
Thanks for your work on this! Cheers ✌️ |
Hey @renatodeleao ! Thank you for creating a minimal test case, I really appreciate that! I know little about vue, but from what I see, the code inside |
Thank you for looking at it!
Yes it's normal and expected 🤦, i'm sry for polluting this thread, I should have used A watcher is a more common pattern for when the |
@renatodeleao No problem, glad we were able figure it out. Don't hesitate to report any other other issues using vue, I don't have a lot of opportunities to do it myself |
Based on the name of this library I would have assumed that it was testing-library-agnostic, but it uses jest-specific mocking functions and therefore can't be used with other libraries like Vitest that also use the jsdom environment. I would love to see compatibility expanded, perhaps by providing a configuration option to provide the desired mocking functions or by detecting which testing library is in use.
The text was updated successfully, but these errors were encountered: