chore(angular): hide warnings from angular schematics in jest execution (#12122)
This commit is contained in:
parent
ed7db7c114
commit
9313af0493
@ -8,4 +8,5 @@ export default {
|
||||
displayName: 'angular',
|
||||
testEnvironment: 'node',
|
||||
preset: '../../jest.preset.js',
|
||||
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
|
||||
};
|
||||
|
||||
31
packages/angular/test-setup.ts
Normal file
31
packages/angular/test-setup.ts
Normal 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 {}
|
||||
}
|
||||
@ -11,7 +11,8 @@
|
||||
"**/*.test.ts",
|
||||
"**/*_spec.ts",
|
||||
"**/*_test.ts",
|
||||
"jest.config.ts"
|
||||
"jest.config.ts",
|
||||
"test-setup.ts"
|
||||
],
|
||||
"include": ["**/*.ts"]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user