1namespace ts.tscWatch { 2 describe("unittests:: tsc-watch:: console clearing", () => { 3 const scenario = "consoleClearing"; 4 const file: File = { 5 path: "/f.ts", 6 content: "" 7 }; 8 9 const makeChangeToFile: TscWatchCompileChange[] = [{ 10 caption: "Comment added to file f", 11 change: sys => sys.modifyFile(file.path, "//"), 12 timeouts: runQueuedTimeoutCallbacks, 13 }]; 14 15 function checkConsoleClearingUsingCommandLineOptions(subScenario: string, commandLineOptions?: string[]) { 16 verifyTscWatch({ 17 scenario, 18 subScenario, 19 commandLineArgs: ["--w", file.path, ...commandLineOptions || emptyArray], 20 sys: () => createWatchedSystem([file, libFile]), 21 changes: makeChangeToFile, 22 }); 23 } 24 25 checkConsoleClearingUsingCommandLineOptions("without --diagnostics or --extendedDiagnostics"); 26 checkConsoleClearingUsingCommandLineOptions("with --diagnostics", ["--diagnostics"]); 27 checkConsoleClearingUsingCommandLineOptions("with --extendedDiagnostics", ["--extendedDiagnostics"]); 28 checkConsoleClearingUsingCommandLineOptions("with --preserveWatchOutput", ["--preserveWatchOutput"]); 29 30 describe("when preserveWatchOutput is true in config file", () => { 31 const compilerOptions: CompilerOptions = { 32 preserveWatchOutput: true 33 }; 34 const configFile: File = { 35 path: "/tsconfig.json", 36 content: JSON.stringify({ compilerOptions }) 37 }; 38 const files = [file, configFile, libFile]; 39 it("using createWatchOfConfigFile ", () => { 40 const baseline = createBaseline(createWatchedSystem(files)); 41 const watch = createWatchProgram(createWatchCompilerHostOfConfigFileForBaseline({ 42 system: baseline.sys, 43 cb: baseline.cb, 44 configFileName: configFile.path, 45 })); 46 // Initially console is cleared if --preserveOutput is not provided since the config file is yet to be parsed 47 runWatchBaseline({ 48 scenario, 49 subScenario: "when preserveWatchOutput is true in config file/createWatchOfConfigFile", 50 commandLineArgs: ["--w", "-p", configFile.path], 51 ...baseline, 52 getPrograms: () => [[watch.getCurrentProgram().getProgram(), watch.getCurrentProgram()]], 53 changes: makeChangeToFile, 54 watchOrSolution: watch 55 }); 56 }); 57 verifyTscWatch({ 58 scenario, 59 subScenario: "when preserveWatchOutput is true in config file/when createWatchProgram is invoked with configFileParseResult on WatchCompilerHostOfConfigFile", 60 commandLineArgs: ["--w", "-p", configFile.path], 61 sys: () => createWatchedSystem(files), 62 changes: makeChangeToFile, 63 }); 64 }); 65 }); 66} 67