• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1namespace ts.tscWatch {
2    describe("unittests:: tsbuildWatch:: watchMode:: configFileErrors:: reports syntax errors in config file", () => {
3        function build(sys: WatchedSystem) {
4            sys.checkTimeoutQueueLengthAndRun(1); // build the project
5            sys.checkTimeoutQueueLength(0);
6        }
7        verifyTscWatch({
8            scenario: "configFileErrors",
9            subScenario: "reports syntax errors in config file",
10            sys: () => createWatchedSystem(
11                [
12                    { path: `${projectRoot}/a.ts`, content: "export function foo() { }" },
13                    { path: `${projectRoot}/b.ts`, content: "export function bar() { }" },
14                    {
15                        path: `${projectRoot}/tsconfig.json`,
16                        content: Utils.dedent`
17{
18    "compilerOptions": {
19        "composite": true,
20    },
21    "files": [
22        "a.ts"
23        "b.ts"
24    ]
25}`
26                    },
27                    libFile
28                ],
29                { currentDirectory: projectRoot }
30            ),
31            commandLineArgs: ["--b", "-w"],
32            changes: [
33                {
34                    caption: "reports syntax errors after change to config file",
35                    change: sys => replaceFileText(sys, `${projectRoot}/tsconfig.json`, ",", `,
36        "declaration": true,`),
37                    timeouts: build,
38                },
39                {
40                    caption: "reports syntax errors after change to ts file",
41                    change: sys => replaceFileText(sys, `${projectRoot}/a.ts`, "foo", "fooBar"),
42                    timeouts: build,
43                },
44                {
45                    caption: "reports error when there is no change to tsconfig file",
46                    change: sys => replaceFileText(sys, `${projectRoot}/tsconfig.json`, "", ""),
47                    timeouts: build,
48                },
49                {
50                    caption: "builds after fixing config file errors",
51                    change: sys => sys.writeFile(`${projectRoot}/tsconfig.json`, JSON.stringify({
52                        compilerOptions: { composite: true, declaration: true },
53                        files: ["a.ts", "b.ts"]
54                    })),
55                    timeouts: build,
56                }
57            ]
58        });
59    });
60}