“Bun test: Fixing \”0 test files matching\” Errors”
bun test stops with "error: 0 test files matching …" when there are no files under the folder you run it from that Bun treats as test files (names like *.test.ts). Rename the file to a form like price.test.ts, move it out of a folder that starts with a dot, or run the command from the folder that contains the tests, and the error goes away.
This comes up when a __tests__ folder stops running after moving from Jest to Bun, or when a CI job changes its working folder and finds zero tests. I deliberately caused this error for each cause in a test environment, then confirmed the message and that fixing each cause made it go away.
The test environment was Ubuntu 24.04 with Bun 1.4.4. I wrote the tests in TypeScript and used only bun:test (no packages installed). The project was at the example path /path/to/app, so the paths in the output are as shown. I did not test Windows, macOS, other Bun versions, or workspace (monorepo) layouts.
- 1. The
--cwdin the message is the folder where Bun started looking - 2. The file name does not contain ".test" or similar
- 3. Jest's
__tests__folder is not searched by default - 4. Files inside folders that start with a dot are not searched
- 5. You are running from a folder with no tests
- 6. Similar messages and their causes
- 7. Sometimes you get zero tests and no error
The --cwd in the message is the folder where Bun started looking
I ran bun test in a project with src/price.ts, which calculates the price including tax, and its test file named src/price-test.ts.
$ find . -type f -not -path './node_modules/*' | sort
./package.json
./src/price-test.ts
./src/price.ts
$ bun test
bun test v1.4.4 (38afee6c8)
error: 0 test files matching **{.test,.spec,_test_,_spec_}.{js,ts,jsx,tsx} in --cwd="/path/to/app"
The exit code was 1, so a CI job fails at this point. The first half of the message gives the naming rule, and --cwd="…" in the second half is the folder where Bun started searching for test files. By default, Bun starts from the current folder (official docs on the folder where the search starts) and walks down through it to find test files (official docs on how test files are discovered).
However, the naming rule in the first half of the message does not fully match the actual rule. In my tests, price_test.ts was found even though the message listed _test_, and price.test.mts and price.test.cts were found even though mts and cts were not in the message. Check the naming rules in the docs, not in the message.
The file name does not contain ".test" or similar
According to the official docs, a file is treated as a test file when its name ends with one of these:
.test.ts(for example,price.test.ts)_test.ts(for example,price_test.ts).spec.ts(for example,price.spec.ts)_spec.ts(for example,price_spec.ts)
Besides ts, the extensions js, jsx, tsx, mjs, cjs, mts, and cts also work. The price-test.ts from earlier does not match, because the character before test is a hyphen. When I renamed it to price.test.ts, the error went away.
$ mv src/price-test.ts src/price.test.ts
$ bun test
bun test v1.4.4 (38afee6c8)
1 pass
0 fail
1 expect() calls
Ran 1 test across 1 file. [4.00ms]
A name that uses a plural test, such as price.tests.ts, also gave the same "0 test files matching" error.
Jest's __tests__ folder is not searched by default
Jest's default testMatch setting treats .js, .ts, and other files inside a __tests__ folder as tests, even without .test in the name. Bun does not have this rule. When I put only __tests__/price.ts in a project and ran bun test, it ended with the same "0 test files matching" error.
If you name the file directly with bun test __tests__/price.ts, you get a different message.
$ bun test __tests__/price.ts
bun test v1.4.4 (38afee6c8)
The following filters did not match any test files in --cwd="/path/to/app":
__tests__/price.ts
5 files were searched [2.00ms]
note: Tests need ".test", "_test_", ".spec" or "_spec_" in the filename (ex: "MyApp.test.ts")
note: To treat the "__tests__/price.ts" filter as a path, run "bun test ./__tests__/price.ts"
Arguments to bun test are not treated as file paths. They are treated as a filter that runs only the test files whose path contains that text (official docs on filtering). __tests__/price.ts was never found as a test file, so filtering for it matches zero files. As the second note says, passing it as a path with ./ worked even though the file does not match the naming rule.
$ bun test ./__tests__/price.ts
bun test v1.4.4 (38afee6c8)
1 pass
0 fail
1 expect() calls
Ran 1 test across 1 file. [7.00ms]
However, a plain bun test with no arguments does not find this file. When I renamed it to __tests__/price.test.ts and kept the folder, a plain bun test found it.
Files inside folders that start with a dot are not searched
When I put a test at .tests/price.test.ts, the name matched the rule, but I still got "0 test files matching".
$ find . -type f -not -path './node_modules/*' | sort
./.tests/price.test.ts
./package.json
./src/price.ts
$ bun test
bun test v1.4.4 (38afee6c8)
error: 0 test files matching **{.test,.spec,_test_,_spec_}.{js,ts,jsx,tsx} in --cwd="/path/to/app"
bun test does not search node_modules or folders whose names start with a dot (official docs on where Bun does not search). Passing the path directly, as in bun test ./.tests/price.test.ts, worked. To have a plain bun test find it, rename the folder to tests.
$ mkdir tests && mv .tests/price.test.ts tests/price.test.ts && rmdir .tests
$ bun test
bun test v1.4.4 (38afee6c8)
1 pass
0 fail
1 expect() calls
Ran 1 test across 1 file. [4.00ms]
You are running from a folder with no tests
If the file name and location are correct but you still get the error, check the folder shown in --cwd="…". When I ran from the docs folder in the project, which has no tests, I got this:
$ cd docs && bun test
bun test v1.4.4 (38afee6c8)
error: 0 test files matching **{.test,.spec,_test_,_spec_}.{js,ts,jsx,tsx} in --cwd="/path/to/app/docs"
bun test does not search above the folder you run it from. When I ran it from the folder that contains package.json, it found tests/price.test.ts. If this error shows up in CI, check whether the working folder of the step that runs the tests matches the --cwd in the message.
Similar messages and their causes
Other messages for missing tests had these forms. The wording tells you the cause.
| Command run | Message | Cause |
|---|---|---|
bun test prise |
The following filters did not match any test files in --cwd="/path/to/app": |
No test file matches the filter text (here, a typo of price) |
bun test ./tests/prise.test.ts |
Test filter "./tests/prise.test.ts" had no matches in --cwd="/path/to/app" |
No file exists at the path passed with ./ |
bun test (with root = "./test" in bunfig.toml) |
Failed to scan non-existent root directory for tests: "/path/to/app/test" in --cwd="/path/to/app" |
The folder set in root in bunfig.toml does not exist |
All of these exited with code 1. The root setting under [test] in bunfig.toml changes the folder where test discovery starts (official docs on root). My folder was actually named tests, so I changed it to root = "./tests", and the tests were found and passed.
Sometimes you get zero tests and no error
When I passed an ordinary file that contains no tests, using ./, there was no error.
$ bun test ./src/price.ts
bun test v1.4.4 (38afee6c8)
0 pass
0 fail
Ran 0 tests across 1 file. [2.00ms]
The exit code was 0. If you pass a different file by mistake instead of a test file, CI passes. If you see Ran 0 tests, check the paths you passed.
bun test --help lists --pass-with-no-tests, which makes the exit code 0 even when no tests are found. When I ran it in a folder with no tests, the "0 test files matching" message still appeared, but the exit code was 0. If you add this flag to stop a CI failure, you can no longer notice that no tests ran at all.





