Best JavaScript code snippet using stryker-parent
typescript-checker.ts
Source:typescript-checker.ts
...49 * Starts the typescript compiler and does a dry run50 */51 public async init(): Promise<void> {52 guardTSVersion();53 this.guardTSConfigFileExists();54 this.currentTask = new Task();55 const buildModeEnabled = determineBuildModeEnabled(this.tsconfigFile);56 const compiler = ts.createSolutionBuilderWithWatch(57 ts.createSolutionBuilderWithWatchHost(58 {59 ...ts.sys,60 readFile: (fileName) => {61 const content = this.fs.getFile(fileName)?.content;62 if (content && this.allTSConfigFiles.has(path.resolve(fileName))) {63 return this.adjustTSConfigFile(fileName, content, buildModeEnabled);64 }65 return content;66 },67 watchFile: (filePath: string, callback: ts.FileWatcherCallback) => {68 this.fs.watchFile(filePath, callback);69 return {70 close: () => {71 delete this.fs.getFile(filePath)!.watcher;72 },73 };74 },75 writeFile: (filePath, data) => {76 this.fs.writeFile(filePath, data);77 },78 createDirectory: () => {79 // Idle, no need to create directories in the hybrid fs80 },81 clearScreen() {82 // idle, never clear the screen83 },84 getModifiedTime: (fileName) => {85 return this.fs.getFile(fileName)!.modifiedTime;86 },87 watchDirectory: (): ts.FileWatcher => {88 // this is used to see if new files are added to a directory. Can safely be ignored for mutation testing.89 return {90 // eslint-disable-next-line @typescript-eslint/no-empty-function91 close() {},92 };93 },94 },95 undefined,96 (error) => this.currentErrors.push(error),97 (status) => this.logDiagnostic('status')(status),98 (summary) => {99 this.logDiagnostic('summary')(summary);100 summary.code !== FILE_CHANGE_DETECTED_DIAGNOSTIC_CODE && this.resolveCheckResult();101 }102 ),103 [this.tsconfigFile],104 {}105 );106 compiler.build();107 const result = await this.currentTask.promise;108 if (result.status === CheckStatus.CompileError) {109 throw new Error(`TypeScript error(s) found in dry run compilation: ${result.reason}`);110 }111 }112 private guardTSConfigFileExists() {113 if (!ts.sys.fileExists(this.tsconfigFile)) {114 throw new Error(115 `The tsconfig file does not exist at: "${path.resolve(116 this.tsconfigFile117 )}". Please configure the tsconfig file in your stryker.conf file using "${propertyPath<StrykerOptions>('tsconfigFile')}"`118 );119 }120 }121 /**122 * Checks whether or not a mutant results in a compile error.123 * Will simply pass through if the file mutated isn't part of the typescript project124 * @param mutant The mutant to check125 */126 public async check(mutant: Mutant): Promise<CheckResult> {...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!