Skip to content

Commit f128a33

Browse files
authored
test: fix schematic test infrastructure failing with Angular CLI v10 (#19749)
Angular CLI v10 generates tsconfig files with comments inside it. This breaks our testing infrastructure for schematics that leverages the basic `JSON.parse`. To not throw for such tsconfig files that are parsed by our testing infrastructure, we need to use JSON5.
1 parent e086544 commit f128a33

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/cdk/schematics/testing/test-case-setup.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
9-
import {getSystemPath, normalize, Path} from '@angular-devkit/core';
8+
import {getSystemPath, JsonParseMode, normalize, parseJson, Path} from '@angular-devkit/core';
109
import {TempScopedNodeJsSyncHost} from '@angular-devkit/core/node/testing';
1110
import * as virtualFs from '@angular-devkit/core/src/virtual-fs/host';
1211
import {HostTree, Tree} from '@angular-devkit/schematics';
@@ -94,7 +93,10 @@ export async function createTestCaseSetup(migrationName: string, collectionPath:
9493
});
9594

9695
const testAppTsconfigPath = 'projects/cdk-testing/tsconfig.app.json';
97-
const testAppTsconfig = JSON.parse(appTree.readContent(testAppTsconfigPath));
96+
// Parse TypeScript configuration files with JSON5 as they could contain comments or
97+
// unquoted properties.
98+
const testAppTsconfig =
99+
parseJson(appTree.readContent(testAppTsconfigPath), JsonParseMode.Json5) as any;
98100

99101
// include all TypeScript files in the project. Otherwise all test input
100102
// files won't be part of the program and cannot be migrated.

0 commit comments

Comments
 (0)