diff options
| author | 2023-01-19 15:47:51 -0800 | |
|---|---|---|
| committer | 2023-01-19 15:48:03 -0800 | |
| commit | 8745f10cd3ac16815f5528c0d87606c56b1367c7 (patch) | |
| tree | ae6d85936b0f8034119b6ebb699345319765b4f5 /test/bun.js/install | |
| parent | ac0dab3679ab610f247bddc9c34f6d4692afc9c4 (diff) | |
| download | bun-8745f10cd3ac16815f5528c0d87606c56b1367c7.tar.gz bun-8745f10cd3ac16815f5528c0d87606c56b1367c7.tar.zst bun-8745f10cd3ac16815f5528c0d87606c56b1367c7.zip | |
Improve error message when a workspace is not found
Diffstat (limited to 'test/bun.js/install')
| -rw-r--r-- | test/bun.js/install/bad-workspace.test.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/bun.js/install/bad-workspace.test.ts b/test/bun.js/install/bad-workspace.test.ts new file mode 100644 index 000000000..5fdd54ed3 --- /dev/null +++ b/test/bun.js/install/bad-workspace.test.ts @@ -0,0 +1,37 @@ +import { spawnSync } from "bun"; +import { test, describe, expect } from "bun:test"; +import { bunEnv } from "bunEnv"; +import { bunExe } from "bunExe"; +import { mkdirSync, rmSync, writeFileSync } from "fs"; + +test("bad workspace path", () => { + const cwd = "/tmp/bun-bad-workspace"; + rmSync(cwd, { recursive: true, force: true }); + mkdirSync(cwd); + writeFileSync( + `${cwd}/package.json`, + JSON.stringify( + { + name: "hey", + workspaces: ["i-dont-exist", "*/i-have-a-star-and-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(text).toContain( + 'Workspace not found "*/i-have-a-star-and-i-dont-exist"', + ); + expect(exitCode).toBe(1); + rmSync(cwd, { recursive: true, force: true }); +}); |
