Skip to content

Commit

Permalink
chore(angular): hide warnings from angular schematics in jest executi…
Browse files Browse the repository at this point in the history
…on (nrwl#12122)
  • Loading branch information
AgentEnder authored Sep 20, 2022
1 parent ed7db7c commit 9313af0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/angular/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export default {
displayName: 'angular',
testEnvironment: 'node',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
};
31 changes: 31 additions & 0 deletions packages/angular/test-setup.ts
Original file line number Diff line number Diff line change
@@ -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 {}
}
3 changes: 2 additions & 1 deletion packages/angular/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"**/*.test.ts",
"**/*_spec.ts",
"**/*_test.ts",
"jest.config.ts"
"jest.config.ts",
"test-setup.ts"
],
"include": ["**/*.ts"]
}

0 comments on commit 9313af0

Please sign in to comment.