React Testing Library's automatic cleanup hooks into a global
afterEach, which doesn't exist without globals, so you must call cleanup() in a setup fileRTL (React Testing Library) unmounts rendered trees after each test only if it finds a global afterEach to hook into. With Vitest globals off, that global does not exist, so old renders stay in the DOM. Fix it: add afterEach(() => cleanup()) in a setup file, or set globals: true. The option about tests running in parallel is wrong. Tests inside one file run one after another by default.
Read more