Skip to content

test: fix schematic test infrastructure failing with Angular CLI v10 #19749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/cdk/schematics/testing/test-case-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {getSystemPath, normalize, Path} from '@angular-devkit/core';
import {getSystemPath, JsonParseMode, normalize, parseJson, Path} from '@angular-devkit/core';
import {TempScopedNodeJsSyncHost} from '@angular-devkit/core/node/testing';
import * as virtualFs from '@angular-devkit/core/src/virtual-fs/host';
import {HostTree, Tree} from '@angular-devkit/schematics';
Expand Down Expand Up @@ -94,7 +93,10 @@ export async function createTestCaseSetup(migrationName: string, collectionPath:
});

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit that can be addressed later: I think TS has an interface for the config somewhere which we could reference here instead of any.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is such an interface. IIRC there is only ts.CompilerOptions and that deals only with the compiler options, and also relies on enum values. Let me know if you find something. That would definitely be ideal 😄

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In language service ts.readConfigFile() is used to parse JSON. It returns any though.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@devversion devversion Jun 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be a good alternative. Might just use that one when I come across it again. Looks like it would require us to handle parse diagnostics manually though.


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