• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1namespace ts {
2    describe("unittests:: tsbuild:: with rootDir of project reference in parentDirectory", () => {
3        let projFs: vfs.FileSystem;
4        before(() => {
5            projFs = loadProjectFromDisk("tests/projects/projectReferenceWithRootDirInParent");
6        });
7
8        after(() => {
9            projFs = undefined!; // Release the contents
10        });
11
12        verifyTsc({
13            scenario: "projectReferenceWithRootDirInParent",
14            subScenario: "builds correctly",
15            fs: () => projFs,
16            commandLineArgs: ["--b", "/src/src/main", "/src/src/other"],
17        });
18
19        verifyTsc({
20            scenario: "projectReferenceWithRootDirInParent",
21            subScenario: "reports error for same tsbuildinfo file because no rootDir in the base",
22            fs: () => projFs,
23            commandLineArgs: ["--b", "/src/src/main", "--verbose"],
24            modifyFs: fs => replaceText(fs, "/src/tsconfig.base.json", `"rootDir": "./src/",`, ""),
25        });
26
27        verifyTsc({
28            scenario: "projectReferenceWithRootDirInParent",
29            subScenario: "reports error for same tsbuildinfo file",
30            fs: () => projFs,
31            commandLineArgs: ["--b", "/src/src/main", "--verbose"],
32            modifyFs: fs => {
33                fs.writeFileSync("/src/src/main/tsconfig.json", JSON.stringify({
34                    compilerOptions: { composite: true, outDir: "../../dist/" },
35                    references: [{ path: "../other" }]
36                }));
37                fs.writeFileSync("/src/src/other/tsconfig.json", JSON.stringify({
38                    compilerOptions: { composite: true, outDir: "../../dist/" },
39                }));
40            },
41        });
42
43        verifyTsc({
44            scenario: "projectReferenceWithRootDirInParent",
45            subScenario: "reports no error when tsbuildinfo differ",
46            fs: () => projFs,
47            commandLineArgs: ["--b", "/src/src/main/tsconfig.main.json", "--verbose"],
48            modifyFs: fs => {
49                fs.renameSync("/src/src/main/tsconfig.json", "/src/src/main/tsconfig.main.json");
50                fs.renameSync("/src/src/other/tsconfig.json", "/src/src/other/tsconfig.other.json");
51                fs.writeFileSync("/src/src/main/tsconfig.main.json", JSON.stringify({
52                    compilerOptions: { composite: true, outDir: "../../dist/" },
53                    references: [{ path: "../other/tsconfig.other.json" }]
54                }));
55                fs.writeFileSync("/src/src/other/tsconfig.other.json", JSON.stringify({
56                    compilerOptions: { composite: true, outDir: "../../dist/" },
57                }));
58            },
59        });
60    });
61}
62