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