* Set up a new testing environment.
(files: Folder = {}, workingDir?: AbsoluteFsPath)
| 78 | * Set up a new testing environment. |
| 79 | */ |
| 80 | static setup(files: Folder = {}, workingDir?: AbsoluteFsPath): NgtscTestEnvironment { |
| 81 | const fs = getFileSystem(); |
| 82 | if (fs instanceof MockFileSystem) { |
| 83 | fs.init(files); |
| 84 | } |
| 85 | |
| 86 | const host = new AugmentedCompilerHost(fs); |
| 87 | setWrapHostForTest(makeWrapHost(host)); |
| 88 | |
| 89 | workingDir = workingDir ?? absoluteFrom('/'); |
| 90 | const env = new NgtscTestEnvironment(fs, fs.resolve('/built'), workingDir); |
| 91 | fs.chdir(workingDir); |
| 92 | |
| 93 | env.write( |
| 94 | absoluteFrom('/tsconfig-base.json'), |
| 95 | `{ |
| 96 | "compilerOptions": { |
| 97 | "emitDecoratorMetadata": false, |
| 98 | "strictPropertyInitialization": false, |
| 99 | "experimentalDecorators": true, |
| 100 | "skipLibCheck": true, |
| 101 | "noImplicitAny": true, |
| 102 | "noEmitOnError": true, |
| 103 | "strictNullChecks": true, |
| 104 | "outDir": "built", |
| 105 | "rootDir": ".", |
| 106 | "allowJs": true, |
| 107 | "declaration": true, |
| 108 | "target": "es2015", |
| 109 | "newLine": "lf", |
| 110 | "module": "es2015", |
| 111 | "moduleResolution": "bundler", |
| 112 | "lib": ["es2015", "dom"], |
| 113 | "typeRoots": ["node_modules/@types"] |
| 114 | }, |
| 115 | "exclude": [ |
| 116 | "built" |
| 117 | ] |
| 118 | }`, |
| 119 | ); |
| 120 | |
| 121 | return env; |
| 122 | } |
| 123 | |
| 124 | assertExists(fileName: string) { |
| 125 | if (!this.fs.exists(this.fs.resolve(this.outDir, fileName))) { |
no test coverage detected