chore(angular): hide warnings from angular schematics in jest execution (#12122)

This commit is contained in:
Craigory Coppola 2022-09-20 12:12:23 -04:00 committed by GitHub
parent ed7db7c114
commit 9313af0493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 1 deletions

View File

@ -8,4 +8,5 @@ export default {
displayName: 'angular',
testEnvironment: 'node',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
};

View File

@ -0,0 +1,31 @@
const allowedProjectExtensions = [
'tags',
'implicitDependencies',
'configFilePath',
'$schema',
'generators',
];
const possiblePaths = [
'@schematics/angular/node_modules/@angular-devkit/core/src/workspace/json/reader',
'@angular-devkit/core/src/workspace/json/reader',
];
for (const possiblePath of possiblePaths) {
try {
jest.mock(possiblePath, () => {
const originalModule = jest.requireActual(
possiblePath
) as typeof import('@angular-devkit/core/src/workspace/json/reader');
const originalReadJsonWorkspace = originalModule.readJsonWorkspace;
return {
...originalModule,
readJsonWorkspace: async (path, host, options) => {
return originalReadJsonWorkspace(path, host, {
...options,
allowedProjectExtensions,
});
},
};
});
} catch {}
}

View File

@ -11,7 +11,8 @@
"**/*.test.ts",
"**/*_spec.ts",
"**/*_test.ts",
"jest.config.ts"
"jest.config.ts",
"test-setup.ts"
],
"include": ["**/*.ts"]
}