mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
* Fixes #8964 * Fix test.each when used with test.only --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
// This test passes by simply running it. It is a regression test for issue #8964
|
|
import { describe, test, afterAll } from "bun:test";
|
|
|
|
var expected: number[] = [];
|
|
var runs: number[] = [];
|
|
var count = 0;
|
|
function makeTest(yes = false) {
|
|
const thisCount = count++;
|
|
if (yes) expected.push(thisCount);
|
|
test("test " + thisCount, () => {
|
|
runs.push(thisCount);
|
|
});
|
|
}
|
|
|
|
describe("Outer", () => {
|
|
describe.only("Inner", () => {
|
|
describe("Inside Only", () => {
|
|
makeTest(true);
|
|
});
|
|
makeTest(true);
|
|
|
|
expected.push(997, 998, 999);
|
|
test.each([997, 998, 999])("test %i", i => {
|
|
runs.push(i);
|
|
});
|
|
});
|
|
|
|
test.each([2997, 2998, 2999])("test %i", i => {
|
|
runs.push(i);
|
|
});
|
|
|
|
describe("Inner #2", () => {
|
|
makeTest();
|
|
describe("Inside Inner #2", () => {
|
|
makeTest();
|
|
describe.only("Inside Inner #2 Only", () => {
|
|
makeTest(true);
|
|
});
|
|
});
|
|
});
|
|
makeTest();
|
|
});
|
|
|
|
afterAll(() => {
|
|
if (runs.length !== expected.length) {
|
|
console.error(new Error("Test count mismatch"));
|
|
process.exit(1);
|
|
}
|
|
if (runs.sort().join(",") !== expected.sort().join(",")) {
|
|
console.error(new Error("Test order mismatch"));
|
|
process.exit(1);
|
|
}
|
|
});
|