Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/bake/dev/import-meta-inline-negative.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, test } from "bun:test";
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
import { bunEnv, bunExe, tempDir } from "harness";

test("import.meta properties are NOT inlined without bake framework", async () => {
const dir = tempDirWithFiles("import-meta-no-inline", {
await using dir = tempDir("import-meta-no-inline", {
"index.ts": `
console.log("dir:", import.meta.dir);
console.log("dirname:", import.meta.dirname);
Expand Down
12 changes: 6 additions & 6 deletions test/bake/dev/response-to-bake-response.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect, test } from "bun:test";
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
import { bunEnv, bunExe, tempDir } from "harness";
import path from "node:path";

test("Response -> import { Response } from 'bun:app' transform in server components", async () => {
const dir = tempDirWithFiles("response-transform", {
await using dir = tempDir("response-transform", {
"server-component.js": `
export const mode = "ssr";
export const streaming = false;
Expand Down Expand Up @@ -61,7 +61,7 @@ test("Response -> import { Response } from 'bun:app' transform in server compone
});

test("Response import is added for global Response in various contexts", async () => {
const dir = tempDirWithFiles("response-contexts", {
await using dir = tempDir("response-contexts", {
"server.js": `
export const mode = "ssr";

Expand Down Expand Up @@ -102,7 +102,7 @@ test("Response import is added for global Response in various contexts", async (
});

test("Response import is not added when Response is already imported or shadowed", async () => {
const dir = tempDirWithFiles("response-shadowing", {
await using dir = tempDir("response-shadowing", {
"server.js": `
export const mode = "ssr";

Expand Down Expand Up @@ -159,7 +159,7 @@ test("Response import is not added when Response is already imported or shadowed
});

test("Response import is NOT added in client components", async () => {
const dir = tempDirWithFiles("client-no-transform", {
await using dir = tempDir("client-no-transform", {
"client-component.js": `
"use client";

Expand Down Expand Up @@ -219,7 +219,7 @@ test("Response import is NOT added in client components", async () => {
});

test("Response import is added when Response is global, but not when shadowed", async () => {
const dir = tempDirWithFiles("response-shadowing", {
await using dir = tempDir("response-shadowing", {
"server-component.js": `
export const mode = "ssr";

Expand Down
4 changes: 2 additions & 2 deletions test/bake/framework-router.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { frameworkRouterInternals } from "bun:internal-for-testing";
import { describe, expect, test } from "bun:test";
import { tempDirWithFiles } from "harness";
import { tempDir } from "harness";
import path from "path";

const { parseRoutePattern, FrameworkRouter } = frameworkRouterInternals;
Expand Down Expand Up @@ -79,7 +79,7 @@ describe("pattern parse", () => {
});

test("discovers from filesystem paths", () => {
const dir = tempDirWithFiles("fsr", {
using dir = tempDir("fsr", {
"hello.tsx": "1",
"meow/_layout.tsx": "1",
"meow/bark/[param]/hello.tsx": "1",
Expand Down
4 changes: 2 additions & 2 deletions test/bundler/bun-build-compile-wasm.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { describe, expect, test } from "bun:test";
import { bunEnv, tempDirWithFiles } from "harness";
import { bunEnv, tempDir } from "harness";
import { join } from "path";

describe("Bun.build compile with wasm", () => {
test("compile with wasm module imports", async () => {
// This test ensures that embedded wasm modules compile and run correctly
// The regression was that the module prefix wasn't being set correctly

const dir = tempDirWithFiles("build-compile-wasm", {
await using dir = tempDir("build-compile-wasm", {
"app.js": `
// Import a wasm module and properly instantiate it
import wasmPath from "./test.wasm";
Expand Down
6 changes: 3 additions & 3 deletions test/bundler/bundler_compile.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Database } from "bun:sqlite";
import { describe, expect, test } from "bun:test";
import { rmSync } from "fs";
import { bunEnv, bunExe, isWindows, tempDir, tempDirWithFiles } from "harness";
import { bunEnv, bunExe, isWindows, tempDir } from "harness";
import { join } from "path";
import { BundlerTestInput, itBundled as itBundledBase } from "./expectBundled";

Expand Down Expand Up @@ -957,7 +957,7 @@ error: Hello World`,
});

test("does not crash", async () => {
const dir = tempDirWithFiles("bundler-compile-shadcn", {
await using dir = tempDir("bundler-compile-shadcn", {
"frontend.tsx": `console.log("Hello, world!");`,
"index.html": `<!doctype html>
<html lang="en">
Expand Down Expand Up @@ -1072,7 +1072,7 @@ const server = serve({

// When compiling with 8+ entry points, the main entry point should still run correctly.
test("compile with 8+ entry points runs main entry correctly", async () => {
const dir = tempDirWithFiles("compile-many-entries", {
await using dir = tempDir("compile-many-entries", {
"app.js": `console.log("IT WORKS");`,
"assets/file-1": "",
"assets/file-2": "",
Expand Down
6 changes: 3 additions & 3 deletions test/bundler/bundler_defer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
import { bunEnv, bunExe, tempDir } from "harness";
import * as path from "node:path";
import { itBundled } from "./expectBundled";

Expand Down Expand Up @@ -137,7 +137,7 @@ describe("defer", () => {
{
let action: string[] = [];
test("onstart throwing an error works", async () => {
const folder = tempDirWithFiles("plugin", {
await using folder = tempDir("plugin", {
"index.ts": "export const foo = {}",
});
try {
Expand Down Expand Up @@ -467,7 +467,7 @@ console.log("FOOOO", foo);
});

test("integration", async () => {
const folder = tempDirWithFiles("integration", {
await using folder = tempDir("integration", {
"module_data.json": "{}",
"package.json": `{
"name": "integration-test",
Expand Down
4 changes: 2 additions & 2 deletions test/bundler/html-import-manifest.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { tempDirWithFiles } from "harness";
import { tempDir } from "harness";
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { itBundled } from "./expectBundled";
Expand Down Expand Up @@ -364,7 +364,7 @@ console.log("About manifest:", aboutHtml);
// changes; otherwise the browser 304s to a body that points at chunks the
// server no longer has.
test("html-import/etag-changes-with-referenced-chunks", async () => {
const dir = tempDirWithFiles("html-etag", {
await using dir = tempDir("html-etag", {
"server.ts": `import m from "./index.html"; console.log(JSON.stringify(m));`,
"index.html": `<!doctype html><script type="module" src="./app.ts"></script>`,
"app.ts": `console.log(1);`,
Expand Down
12 changes: 6 additions & 6 deletions test/cli/bunfig-test-options.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, test } from "bun:test";
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
import { bunEnv, bunExe, tempDir } from "harness";

describe("bunfig.toml test options", () => {
test("randomize with seed produces consistent order", async () => {
const dir = tempDirWithFiles("bunfig-test-randomize-seed", {
await using dir = tempDir("bunfig-test-randomize-seed", {
"test.test.ts": `
import { test, expect } from "bun:test";
test("alpha", () => {
Expand Down Expand Up @@ -76,7 +76,7 @@ describe("bunfig.toml test options", () => {
});

test("seed without randomize errors", async () => {
const dir = tempDirWithFiles("bunfig-test-seed-no-randomize", {
await using dir = tempDir("bunfig-test-seed-no-randomize", {
"test.test.ts": `
import { test, expect } from "bun:test";
test("test 1", () => expect(1).toBe(1));
Expand Down Expand Up @@ -105,7 +105,7 @@ describe("bunfig.toml test options", () => {
});

test("seed with randomize=false errors", async () => {
const dir = tempDirWithFiles("bunfig-test-seed-randomize-false", {
await using dir = tempDir("bunfig-test-seed-randomize-false", {
"test.test.ts": `
import { test, expect } from "bun:test";
test("test 1", () => expect(1).toBe(1));
Expand Down Expand Up @@ -134,7 +134,7 @@ describe("bunfig.toml test options", () => {
});

test("rerunEach option works", async () => {
const dir = tempDirWithFiles("bunfig-test-rerun-each", {
await using dir = tempDir("bunfig-test-rerun-each", {
"test.test.ts": `
import { test, expect } from "bun:test";
let counter = 0;
Expand Down Expand Up @@ -168,7 +168,7 @@ describe("bunfig.toml test options", () => {
});

test("all test options together", async () => {
const dir = tempDirWithFiles("bunfig-test-all-options", {
await using dir = tempDir("bunfig-test-all-options", {
"test.test.ts": `
import { test, expect } from "bun:test";
test("test 1", () => expect(1).toBe(1));
Expand Down
20 changes: 10 additions & 10 deletions test/cli/console-depth.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
import { bunEnv, bunExe, tempDir } from "harness";

describe("console depth", () => {
const deepObject = {
Expand Down Expand Up @@ -32,7 +32,7 @@ describe("console depth", () => {
}

test("default console depth should be 2", async () => {
const dir = tempDirWithFiles("console-depth-default", {
await using dir = tempDir("console-depth-default", {
"test.js": testScript,
});

Expand Down Expand Up @@ -62,7 +62,7 @@ describe("console depth", () => {
});

test("--console-depth flag sets custom depth", async () => {
const dir = tempDirWithFiles("console-depth-cli", {
await using dir = tempDir("console-depth-cli", {
"test.js": testScript,
});

Expand Down Expand Up @@ -94,7 +94,7 @@ describe("console depth", () => {
});

test("--console-depth with higher value shows deeper nesting", async () => {
const dir = tempDirWithFiles("console-depth-high", {
await using dir = tempDir("console-depth-high", {
"test.js": testScript,
});

Expand Down Expand Up @@ -138,7 +138,7 @@ describe("console depth", () => {
});

test("bunfig.toml console.depth configuration", async () => {
const dir = tempDirWithFiles("console-depth-bunfig", {
await using dir = tempDir("console-depth-bunfig", {
"test.js": testScript,
"bunfig.toml": `[console]\ndepth = 4`,
});
Expand Down Expand Up @@ -173,7 +173,7 @@ describe("console depth", () => {
});

test("CLI flag overrides bunfig.toml", async () => {
const dir = tempDirWithFiles("console-depth-override", {
await using dir = tempDir("console-depth-override", {
"test.js": testScript,
"bunfig.toml": `[console]\ndepth = 6`,
});
Expand Down Expand Up @@ -204,7 +204,7 @@ describe("console depth", () => {
});

test("invalid --console-depth value shows error", async () => {
const dir = tempDirWithFiles("console-depth-invalid", {
await using dir = tempDir("console-depth-invalid", {
"test.js": testScript,
});

Expand All @@ -230,7 +230,7 @@ describe("console depth", () => {
});

test("edge case: depth 0 should show infinite depth", async () => {
const dir = tempDirWithFiles("console-depth-zero", {
await using dir = tempDir("console-depth-zero", {
"test.js": testScript,
});

Expand Down Expand Up @@ -274,7 +274,7 @@ describe("console depth", () => {
});

test("bunfig.toml depth=0 should show infinite depth", async () => {
const dir = tempDirWithFiles("console-depth-bunfig-zero", {
await using dir = tempDir("console-depth-bunfig-zero", {
"test.js": testScript,
"bunfig.toml": `[console]\ndepth = 0`,
});
Expand Down Expand Up @@ -326,7 +326,7 @@ describe("console depth", () => {
console.warn("WARN:", obj);
`;

const dir = tempDirWithFiles("console-depth-multiple", {
await using dir = tempDir("console-depth-multiple", {
"test.js": testScriptMultiple,
});

Expand Down
4 changes: 2 additions & 2 deletions test/cli/hot/watch-many-dirs.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { spawn } from "bun";
import { describe, expect, test } from "bun:test";
import { bunEnv, bunExe, forEachLine, isASAN, isCI, tempDirWithFiles } from "harness";
import { bunEnv, bunExe, forEachLine, isASAN, isCI, tempDir } from "harness";
import { mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";

Expand All @@ -12,7 +12,7 @@ describe("--hot with many directories", () => {
"handles 129 directories being updated simultaneously",
async () => {
// Create initial test structure
const tmpdir = tempDirWithFiles("hot-many-dirs", {
await using tmpdir = tempDir("hot-many-dirs", {
"entry.js": `console.log('Initial load');`,
});

Expand Down
4 changes: 2 additions & 2 deletions test/cli/hot/watch.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { spawn } from "bun";
import { describe, expect, test } from "bun:test";
import { bunEnv, bunExe, forEachLine, isBroken, isWindows, tempDirWithFiles } from "harness";
import { bunEnv, bunExe, forEachLine, isBroken, isWindows, tempDir } from "harness";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";

describe.todoIf(isBroken && isWindows)("--watch works", async () => {
for (const watchedFile of ["entry.js", "tmp.js"]) {
test(`with ${watchedFile}`, async () => {
const tmpdir_ = tempDirWithFiles("watch-fixture", {
await using tmpdir_ = tempDir("watch-fixture", {
"tmp.js": "console.log('hello #1')",
"entry.js": "import './tmp.js'",
"package.json": JSON.stringify({ name: "foo", version: "0.0.1" }),
Expand Down
Loading
Loading