What am I doing wrong? Taking longer to run tests with Vitest than Jest! #1747
Unanswered
lukebennett88
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Seeing very similar, literally running a single test file (with 3 tests) and it takes 13 seconds 😮
I have a setup file like this: import { afterEach } from 'vitest';
import { cleanup } from '@testing-library/react';
import '@testing-library/jest-dom/vitest';
afterEach(() => {
cleanup();
}); And my config is similar: test: {
globals: true,
environment: 'jsdom',
setupFiles: '.testrc.js'
}, |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm looking at switching the test framework for the design system I'm working on over to Vitest. We were using a pretty standard Jest/React Testing Library setup right now.
After switching over to Vitest, running the tests on 17 files, and 75 tests takes around 9 seconds on my local machine.
When I run the same tests using Jest, it takes a little over 4 seconds.
I've got a pretty standard looking vitest config:
The
setup-test-env.ts
file above is just this:I'm not sure if this is related or not, but as you can see in my config above I have globals turned on. I uninstalled
@types/jest
from the codebase, but my editor is still picking up types fordescribe
,expect
etc. I ranyarn why @types/jest
and it looks like the types are leaking out from@testing-libarary/jest-dom
. I tried turning globals off, the testing libraryjest-dom
package seems to be relying on them to be turned on as it fails with the errorReferenceError: expect is not defined
. I'd like to turn globals off and import what I'm using, but unless I'm doing something wrong, it doesn't look like I can and still use React Testing Library.Beta Was this translation helpful? Give feedback.
All reactions