vitest-dev / vitest-dev/vitest
Browser mode: Random 'Vitest failed to find the current suite' error in CI
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Describe the bug
Visual tests using @vitest/browser with Playwright randomly fail in CI with the error:
Error: Failed to import test file [path]
Caused by: Error: Vitest failed to find the current suite. This is a bug in Vitest. Please, open an issue with reproduction.
Reproduction
This happens randomly in CI (GitHub Actions) and is not reproducible locally. The same tests pass when re-running CI.
Affected test files pattern: *.visual-test.tsx
Example failing test:
import { render } from "@testing-library/react";
import { expect, test } from "vitest";
test("default empty - desktop", async () => {
render(<MyComponent />);
await expect(document.body).toMatchScreenshot();
});
System Info
Vitest: 4.0.8
@vitest/browser: 4.0.8
@vitest/browser-playwright: 4.0.8
Playwright: latest
OS: Ubuntu (GitHub Actions runner)
Node: 20.x
Behavior
- ✅ Tests pass locally (macOS)
- ❌ Tests randomly fail in CI (GitHub Actions, Ubuntu)
- ✅ Re-running CI usually fixes the issue
- The error occurs at test file import, not during test execution
Frequency
Intermittent - approximately 1 in 5 CI runs fail with this error.
Used Package Manager
pnpm
Validations
- Check that there isn't already an issue that reports the same bug
- The provided reproduction is minimal and clean
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the affected *.visual-test.tsx files with @vitest/browser and Playwright in the GitHub Actions Ubuntu environment, comparing failures with successful reruns. Investigate the import-time "current suite" failure and verify any change against the provided example and intermittent CI behavior; done means the suite no longer fails during test-file import.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, node.js, playwright, typescript
- Domain
- ci-cd, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100