MCPcopy Create free account
hub / github.com/angular/components / createFileSystemTestApp

Function createFileSystemTestApp

src/cdk/schematics/testing/test-case-setup.ts:40–63  ·  view source on GitHub ↗
(runner: SchematicTestRunner)

Source from the content-addressed store, hash-verified

38 * schematic tree. This would allow us to fully take advantage of the virtual file system.
39 */
40export 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
65export async function createTestCaseSetup(
66 migrationName: string,

Callers 1

createTestCaseSetupFunction · 0.85

Calls 2

createTestAppFunction · 0.90
writeFileFunction · 0.85

Tested by

no test coverage detected