Open Janpot opened 1 week ago
Setup file is run only once for the test runner due to --no-isolate
. A single test runner is spawned due to --no-file-parallelism
. The fact that there is a failing test case here doesn't affect anything - even when all tests pass, there is only a single log output.
But *each
handlers should still be called 🤔
Worth mentioning this mode also breaks @testing-library/dom
, see https://github.com/testing-library/dom-testing-library/issues/1337.
How is that related? You need isolation for tests that are manipulating the DOM.
That setup is not using *each
hooks at all. The problem in this issue to me seems to be that afterEach
is treated as afterAll
, same for before*
hooks.
That setup is not using *each hooks at all.
It's (should be) called internally by @testing-library/react
.
You need isolation for tests that are manipulating the DOM.
Why? Shouldn't it work if you disable file parallelism? Isn't that essentially how e.g. mocha
works?
this mode also breaks
@testing-library/dom
It's (should be) called internally by
@testing-library/react
.
Oh right, you are using @testing-library/react
, not @testing-library/dom
. The issue is reported in wrong Github project.
See https://github.com/vitest-dev/vitest/issues/1430 for the root cause there.
The issue is reported in wrong Github project.
They don't accept issues related to the dom query API in the @testing-library/react
repo 🤷
Surprisingly, the behavior is different if you have setupFiles: ['./setup.ts']
instead of setupFiles: ['./setup']
https://stackblitz.com/edit/vitest-dev-vitest-hps2bc?file=vite.config.ts
This isn't probably intended. Module cache invalidation here needs to consider resolution https://github.com/vitest-dev/vitest/blob/5e6de2742f329b7e65fe3dff4827b5134d777009/packages/vitest/src/runtime/runners/test.ts#L35-L40
For the issue with testing-library's cleanup hooks https://github.com/vitest-dev/vitest/issues/1430, that one might be already fixed by https://github.com/vitest-dev/vitest/pull/6689
btw, https://github.com/testing-library/dom-testing-library/issues/1337 is not caused by the @testing-library/react
cleanup hooks, I'm seeing the same behavior without react. I updated the reproduction.
Describe the bug
Logs from
beforeEach
/afterEach
are missing when I run my tests with--no-isolate --no-file-parallelism
and one of the suites has a failing testReproduction
pnpm test run
pnpm test run -- --no-isolate --no-file-parallelism
System Info
Used Package Manager
pnpm
Validations