Files
bun.sh/test/cli/install/bad-workspace.test.ts
2024-05-23 20:24:54 -07:00

41 lines
818 B
TypeScript

import { spawnSync } from "bun";
import { beforeEach, expect, test, beforeAll, setDefaultTimeout } from "bun:test";
import { writeFileSync } from "fs";
import { bunExe, bunEnv, tmpdirSync } from "harness";
let cwd: string;
beforeAll(() => {
setDefaultTimeout(1000 * 60 * 5);
});
beforeEach(() => {
cwd = tmpdirSync();
});
test("bad workspace path", () => {
writeFileSync(
`${cwd}/package.json`,
JSON.stringify(
{
name: "hey",
workspaces: ["i-dont-exist"],
},
null,
2,
),
);
const { stderr, exitCode } = spawnSync({
cmd: [bunExe(), "install"],
cwd,
env: bunEnv,
stderr: "pipe",
stdout: "pipe",
});
const text = stderr!.toString();
expect(text).toContain('Workspace not found "i-dont-exist"');
expect(exitCode).toBe(1);
});