aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/turbo-utils/__tests__/getTurboConfigs.test.ts
blob: e61e630abb1007bd13fb970190332abfd7b8b229 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import path from "path";
import getTurboConfigs from "../src/getTurboConfigs";
import { setupTestFixtures } from "@turbo/test-utils";

describe("getTurboConfigs", () => {
  const { useFixture } = setupTestFixtures({
    directory: path.join(__dirname, "../"),
    test: "common",
  });

  it("single-package", async () => {
    const { root } = useFixture({ fixture: `single-package` });
    const configs = getTurboConfigs(root);
    expect(configs).toHaveLength(1);
    expect(configs[0].isRootConfig).toBe(true);
    expect(configs[0].config).toMatchInlineSnapshot(`
      Object {
        "$schema": "https://turbo.build/schema.json",
        "globalEnv": Array [
          "UNORDERED",
          "CI",
        ],
        "pipeline": Object {
          "build": Object {
            "dependsOn": Array [
              "^build",
            ],
          },
          "deploy": Object {
            "dependsOn": Array [
              "build",
              "test",
              "lint",
            ],
            "outputs": Array [],
          },
          "lint": Object {
            "outputs": Array [],
          },
          "test": Object {
            "dependsOn": Array [
              "build",
            ],
            "inputs": Array [
              "src/**/*.tsx",
              "src/**/*.ts",
              "test/**/*.ts",
              "test/**/*.tsx",
            ],
            "outputs": Array [],
          },
        },
      }
    `);
  });

  it("workspace-configs", async () => {
    const { root } = useFixture({ fixture: `workspace-configs` });
    const configs = getTurboConfigs(root);

    expect(configs).toHaveLength(3);
    expect(configs[0].isRootConfig).toBe(true);
    expect(configs[0].config).toMatchInlineSnapshot(`
      Object {
        "$schema": "https://turbo.build/schema.json",
        "globalEnv": Array [
          "CI",
        ],
        "pipeline": Object {
          "build": Object {
            "env": Array [
              "ENV_1",
            ],
          },
        },
      }
    `);
    expect(configs[1].isRootConfig).toBe(false);
    expect(configs[1].config).toMatchInlineSnapshot(`
      Object {
        "$schema": "https://turbo.build/schema.json",
        "extends": Array [
          "//",
        ],
        "pipeline": Object {
          "build": Object {
            "env": Array [
              "ENV_2",
            ],
          },
        },
      }
    `);

    expect(configs[2].isRootConfig).toBe(false);
    expect(configs[2].config).toMatchInlineSnapshot(`
      Object {
        "$schema": "https://turbo.build/schema.json",
        "extends": Array [
          "//",
        ],
        "pipeline": Object {
          "build": Object {
            "env": Array [
              "IS_SERVER",
            ],
          },
        },
      }
    `);
  });
});