Files
bun.sh/test/js/node/test_runner/fixtures/05-test-in-test.js
190n a1f756fea9 Fix running bun test on multiple node:test tests (#19354)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-24 11:48:55 -07:00

27 lines
1.1 KiB
JavaScript

const { describe, test } = require("node:test");
const assert = require("node:assert");
// for passing to assert.throws
function expectedError(fn) {
return {
name: "NotImplementedError",
message: `${fn}() inside another test() is not yet implemented in Bun. Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/5090. Use \`bun:test\` in the interim.`,
};
}
test("test() inside test() (global context) throws", () => {
assert.throws(() => test("should throw and not run the test callback", assert.fail), expectedError("test"));
});
test("test() inside test() (passed context) throws", t => {
assert.throws(() => t.test("should throw and not run the test callback", assert.fail), expectedError("test"));
});
test("describe() inside test() (global context) throws", () => {
assert.throws(() => describe("should throw and not run the test callback", assert.fail), expectedError("describe"));
});
test("describe() inside test() (passed context) throws", t => {
assert.throws(() => t.describe("should throw and not run the test callback", assert.fail), expectedError("describe"));
});