Bun test "ENOENT" reading a fixture / file in CI
A test tried to open a file and got ENOENT because the path does not exist on the runner. This is usually a fixture referenced by a relative path that assumes a different working directory or an uncommitted file.
What this error means
bun test fails with "ENOENT: no such file or directory, open '...'" pointing at a fixture or data file the test reads.
(fail) parser > parses sample
error: ENOENT: no such file or directory, open 'fixtures/sample.json'Common causes
A relative fixture path tied to the working directory
The test opens fixtures/sample.json relative to the process cwd, which differs in CI from where you ran it locally.
The fixture is not committed or is gitignored
The fixture exists locally but was never committed, or a .gitignore excludes it, so it is absent on the runner.
How to fix it
Resolve fixture paths from the test file
- Build the path from
import.meta.dirso it is independent of cwd. - Confirm the fixture is committed and not gitignored.
- Re-run the test to confirm the file resolves.
import { join } from "path";
const p = join(import.meta.dir, "fixtures", "sample.json");
const data = await Bun.file(p).json();Commit the fixture files
Add the fixtures to version control so the runner has them; check that no ignore rule excludes the directory.
git add fixtures/sample.json
git commit -m "Add test fixture"How to prevent it
- Resolve fixture paths from import.meta.dir, not process cwd.
- Commit all fixtures and verify they are not gitignored.
- Keep test data close to the test file.