Files
bun.sh/test/regression/issue/14029.test.ts
Ashcon Partovi 117e1b3883 bun run prettier (#14153)
Co-authored-by: Electroid <Electroid@users.noreply.github.com>
2024-09-24 22:46:18 -07:00

43 lines
1.1 KiB
TypeScript

import { expect, test } from "bun:test";
import { bunEnv, bunExe, tmpdirSync } from "harness";
import { join } from "path";
test("snapshots will recognize existing entries", async () => {
const testDir = tmpdirSync();
await Bun.write(
join(testDir, "test.test.js"),
`
test("snapshot test", () => {
expect("foo").toMatchSnapshot();
});
`,
);
let proc = Bun.spawnSync({
cmd: [bunExe(), "test", "./test.test.js"],
cwd: testDir,
env: bunEnv,
stdout: "pipe",
stderr: "pipe",
});
expect(proc.stderr.toString()).toContain("1 added");
expect(proc.exitCode).toBe(0);
const newSnapshot = await Bun.file(join(testDir, "__snapshots__", "test.test.js.snap")).text();
// Run the same test, make sure another entry isn't added
proc = Bun.spawnSync({
cmd: [bunExe(), "test", "./test.test.js"],
cwd: testDir,
env: bunEnv,
stdout: "pipe",
stderr: "pipe",
});
expect(proc.stderr.toString()).not.toContain("1 added");
expect(proc.exitCode).toBe(0);
expect(newSnapshot).toBe(await Bun.file(join(testDir, "__snapshots__", "test.test.js.snap")).text());
});