1 | import * as path from "path";
|
2 | import * as fs from "fs-extra";
|
3 | import * as execa from "execa";
|
4 | import { setupFixture } from "backfill-utils-test";
|
5 |
|
6 | import { findPathToBackfill } from "./helper";
|
7 |
|
8 | describe("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 |
|
22 | const ownHash = fs.readdirSync(path.join(packageRoot, hashPath));
|
23 | expect(ownHash).toContain("57f26541cc848f71a80fd9039137f1d50e013b92");
|
24 |
|
25 |
|
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 | });
|