UNPKG

1.19 kBPlain TextView Raw
1import * as path from "path";
2import * as fs from "fs-extra";
3import * as execa from "execa";
4import { setupFixture } from "backfill-utils-test";
5
6import { findPathToBackfill } from "./helper";
7
8describe("End to end", () => {
9 let pathToBackfill: string;
10 let hashPath: string;
11
12 beforeAll(async () => {
13 pathToBackfill = await findPathToBackfill();
14 hashPath = path.join("node_modules", ".cache", "backfill");
15 });
16
17 it("works", async () => {
18 const packageRoot = await setupFixture("basic");
19 await execa("node", [pathToBackfill, "--", "npm run compile"]);
20
21 // Verify it produces the correct hash
22 const ownHash = fs.readdirSync(path.join(packageRoot, hashPath));
23 expect(ownHash).toContain("57f26541cc848f71a80fd9039137f1d50e013b92");
24
25 // ... and that `npm run compile` was run successfully
26 const libFolderExist = await fs.pathExists("lib");
27 expect(libFolderExist).toBe(true);
28 });
29
30 it("fails on error with error code 1", async done => {
31 await setupFixture("basic");
32 const execProcess = execa("node", [pathToBackfill, "--", "somecommand"]);
33
34 execProcess.on("exit", code => {
35 expect(code).toBe(1);
36 done();
37 });
38 });
39});