Compare commits

...

9 Commits

Author SHA1 Message Date
Jarred Sumner
206509282b Merge branch 'main' into jarred/fixes-7849 2024-01-15 21:23:31 -08:00
Jarred Sumner
f77b4865b7 Merge branch 'main' into jarred/fixes-7849 2024-01-11 20:35:49 -08:00
Jarred Sumner
96ef7ad3e2 Merge branch 'main' into jarred/fixes-7849 2024-01-11 15:52:41 -08:00
Jarred Sumner
f00d622ae1 Merge branch 'main' into jarred/fixes-7849 2023-12-29 20:40:30 -08:00
autofix-ci[bot]
3cff7bc3fb [autofix.ci] apply automated fixes 2023-12-29 00:35:47 +00:00
Jarred Sumner
a506d17aa9 Merge branch 'main' into jarred/fixes-7849 2023-12-28 16:34:25 -08:00
Jarred Sumner
ce53c8c510 Merge branch 'main' into jarred/fixes-7849 2023-12-28 16:34:09 -08:00
autofix-ci[bot]
e0f0d5efb5 [autofix.ci] apply automated fixes 2023-12-27 02:34:30 +00:00
Jarred Sumner
68412c0b2a Fixes #7849 2023-12-26 18:33:04 -08:00
4 changed files with 49 additions and 3 deletions

View File

@@ -169,7 +169,7 @@ declare module "bun:test" {
* @param fn the function that defines the tests
*/
export interface Describe {
(label: string, fn: () => void): void;
(label: string | number | Function, fn: () => void): void;
/**
* Skips all other tests, except this group of tests.
*

View File

@@ -1548,6 +1548,16 @@ inline fn createScope(
var function = if (args.len > 1) args[1] else .zero;
var options = if (args.len > 2) args[2] else .zero;
// https://github.com/oven-sh/bun/issues/7849
if (!description.isEmptyOrUndefinedOrNull() and description.isCallable(globalThis.vm())) {
// TODO: do we need an exception check here?
if (description.get(globalThis, "name")) |name| {
if (name.isString()) {
description = name;
}
}
}
if (description.isEmptyOrUndefinedOrNull() or !description.isString()) {
function = description;
description = .zero;

View File

@@ -180,14 +180,17 @@ export function randomPort(): number {
}
expect.extend({
toRun(cmds: string[]) {
toRun(opts: string[] | { cwd: string; cmds: string[]; exitCode?: number }) {
const { cwd, cmds, exitCode = 0 } = Array.isArray(opts) ? { cwd: ".", cmds: opts, exitCode: 0 } : opts;
const result = Bun.spawnSync({
cmd: [bunExe(), ...cmds],
env: bunEnv,
cwd,
stdio: ["inherit", "pipe", "inherit"],
});
if (result.exitCode !== 0) {
if (result.exitCode !== exitCode) {
return {
pass: false,
message: () => `Command ${cmds.join(" ")} failed:` + "\n" + result.stdout.toString("utf-8"),

View File

@@ -0,0 +1,33 @@
import { test, expect } from "bun:test";
import "harness";
import { tempDirWithFiles } from "harness";
test("07849", async () => {
const tempdir = tempDirWithFiles("07849", {
"package.json": JSON.stringify(
{
name: "07849",
version: "0.0.0",
},
null,
2,
),
"index.test.ts": /*ts*/ `
import { test, expect, describe } from "bun:test";
function fn(n: number) {
return n + 1;
}
describe(fn, () => {
test("zero", () => {
process.exit(123);
});
});
`,
});
expect({
cwd: tempdir,
cmds: ["test", "index.test.ts"],
exitCode: 123,
}).toRun();
});