(runner: SchematicTestRunner)
| 38 | * schematic tree. This would allow us to fully take advantage of the virtual file system. |
| 39 | */ |
| 40 | export async function createFileSystemTestApp(runner: SchematicTestRunner) { |
| 41 | const hostTree = new HostTree(); |
| 42 | const appTree: UnitTestTree = await createTestApp(runner, {name: 'cdk-testing'}, hostTree); |
| 43 | |
| 44 | // Since the TypeScript compiler API expects all files to be present on the real file system, we |
| 45 | // map every file in the app tree to a temporary location on the file system. |
| 46 | appTree.files.forEach(f => writeFile(f, appTree.readContent(f))); |
| 47 | |
| 48 | return { |
| 49 | appTree, |
| 50 | writeFile, |
| 51 | }; |
| 52 | |
| 53 | function writeFile(filePath: string, content: string) { |
| 54 | // Update the temp file system host to reflect the changes in the real file system. |
| 55 | // This is still necessary since we depend on the real file system for parsing the |
| 56 | // TypeScript project. |
| 57 | if (hostTree.exists(filePath)) { |
| 58 | hostTree.overwrite(filePath, content); |
| 59 | } else { |
| 60 | hostTree.create(filePath, content); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | export async function createTestCaseSetup( |
| 66 | migrationName: string, |
no test coverage detected