oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.16k stars 2.77k forks source link

`bun test` ignores tests in subsequent files when using a test factory #11660

Open Hexagon opened 5 months ago

Hexagon commented 5 months ago

What version of Bun is running?

1.1.12+43f0913c3

What platform is your computer?

Linux 5.15.0-107-generic x86_64 x86_64

What steps can reproduce the bug?

  1. Create testfactory.js:
import { test } from "bun:test";
export { test }; 
  1. Create two or more test files test1.test.js and test2.test.js:
import { test } from "./testfactory.js";

test('add1', async() => { /* ... */ });
test('add2', async() => { /* ... */ });
import { test } from "./testfactory.js";

test('sub1', async() => { /* ... */ });
test('sub2', async() => { /* ... */ });
  1. Run bun test

What is the expected behavior?

All tests from all test files should be executed.

What do you see instead?

Only the tests from the first file (test1.test.js in this case) are run. The tests from the second file are not discovered or executed.

test2.test.js:
✓ sub1 [0.04ms]
✓ sub2 [0.04ms]

test1.test.js: 

 2 pass
 0 fail
Ran 2 tests across 2 files. [23.00ms]

Additional information

This issue does not occur if I import the test function directly from "bun:test" in each test file, instead of using my test factory (which is just a re-exported test in this example).

Pinta365 commented 5 months ago

Same problem for me on Windows.

Bun version: 1.1.13

OS: Windows 11 Pro