components: bug: Sanity checks run in test environement
As I explained in comment on PR ( https://github.com/angular/components/pull/23289 ) I have a lot of warnings coming from angular material sanity checks during my unit test runs, what makes the output unreadable. @jelbourn advised me to open an issue because sanity checks should not run in test environment.
Thanks for your help !
Steps to reproduce:
- Fork https://github.com/eweap/angular-material-warn
- Run
yarn install
then run test withyarn nx test ui
to run the test for the ui lib (its a nrwl/nx workspace)
Expected Behavior
What behavior were you expecting to see? No warning should be display during the test run
Actual Behavior
What behavior did you actually see? A warning is displayed:
console.warn
Could not find Angular Material core theme. Most Material components may not work as expected. For more info refer to the theming guide: https://material.angular.io/guide/theming
at MatCommonModule.Object.<anonymous>.MatCommonModule._checkThemeIsPresent (../../../src/material/core/common-behaviors/common-module.ts:144:15)
at new MatCommonModule (../../../src/material/core/common-behaviors/common-module.ts:81:12)
at Object.MatCommonModule_Factory [as factory] (../../node_modules/@angular/material/bundles/material-core.umd.js:189:69)
at R3Injector.Object.<anonymous>.R3Injector.hydrate (../../../packages/core/src/di/r3_injector.ts:416:29)
at R3Injector.Object.<anonymous>.R3Injector.get (../../../packages/core/src/di/r3_injector.ts:211:23)
at ../../../packages/core/src/di/r3_injector.ts:247:51
at Set.forEach (<anonymous>)
at R3Injector.Object.<anonymous>.R3Injector._resolveInjectorDefTypes (../../../packages/core/src/di/r3_injector.ts:247:27)
Environment
- Angular: 12.2.1
- CDK/Material: 12.2.1
- Operating System (e.g. Windows, macOS, Ubuntu): Ubuntu
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (9 by maintainers)
Commits related to this issue
- fix(material/core): avoid running sanity checks on some test environments Fixes that the sanity checks were running on some testing environments like Jest. These changes also move the test environme... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): avoid running sanity checks on some test environments Fixes that the sanity checks were running on some testing environments like Jest. These changes also move the test environme... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): avoid running sanity checks on some test environments Fixes that the sanity checks were running on some testing environments like Jest. These changes also move the test environme... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): avoid running sanity checks on some test environments Fixes that the sanity checks were running on some testing environments like Jest. These changes also move the test environme... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): avoid running sanity checks on some test environments (#23374) Fixes that the sanity checks were running on some testing environments like Jest. These changes also move the test ... — committed to angular/components by crisbeto 3 years ago
- fix(material/core): avoid running sanity checks on some test environments (#23374) Fixes that the sanity checks were running on some testing environments like Jest. These changes also move the test ... — committed to angular/components by crisbeto 3 years ago
- fix(material/core): sanity checks not disabled for node-based test environments In #23374 we expanded the logic that checks for test environments to cover Jest and Mocha. The problem is that we were ... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): sanity checks not disabled for node-based test environments In #23374 we expanded the logic that checks for test environments to cover Jest and Mocha. The problem is that we were ... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): sanity checks not disabled for node-based test environments In #23374 we expanded the logic that checks for test environments to cover Jest and Mocha. The problem is that we were ... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): sanity checks not disabled for node-based test environments In #23374 we expanded the logic that checks for test environments to cover Jest and Mocha. The problem is that we were ... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): sanity checks not disabled for node-based test environments In #23374 we expanded the logic that checks for test environments to cover Jest and Mocha. The problem is that we were ... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): sanity checks not disabled for node-based test environments (#23636) In #23374 we expanded the logic that checks for test environments to cover Jest and Mocha. The problem is that... — committed to angular/components by crisbeto 3 years ago
- fix(material/core): sanity checks not disabled for node-based test environments (#23636) In #23374 we expanded the logic that checks for test environments to cover Jest and Mocha. The problem is that... — committed to angular/components by crisbeto 3 years ago
- fix(material/core): test environment check not picking up jest In #23636 the test environment check was changed so that it looks for the test objects either on `window` or `global`, however it looks ... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): test environment check not picking up jest In #23636 the test environment check was changed so that it looks for the test objects either on `window` or `global`, however it looks ... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): test environment check not picking up jest In #23636 the test environment check was changed so that it looks for the test objects either on `window` or `global`, however it looks ... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): test environment check not picking up jest In #23636 the test environment check was changed so that it looks for the test objects either on `window` or `global`, however it looks ... — committed to crisbeto/material2 by crisbeto 3 years ago
- fix(material/core): test environment check not picking up jest (#23722) In #23636 the test environment check was changed so that it looks for the test objects either on `window` or `global`, however ... — committed to angular/components by crisbeto 3 years ago
- fix(material/core): test environment check not picking up jest (#23722) In #23636 the test environment check was changed so that it looks for the test objects either on `window` or `global`, however ... — committed to angular/components by crisbeto 3 years ago
- fix(material/core): test environment check not picking up jest (#23722) In #23636 the test environment check was changed so that it looks for the test objects either on `window` or `global`, however ... — committed to crisbeto/material2 by crisbeto 3 years ago
@crisbeto it looks like we should update our test env check to look for jest
fingers crossed this makes it into 13 (also, hurrah for 13 🎉)
I tried a sample Jest project and could confirm that it doesn’t get published to
global
. I’ve submitted #23722 to hopefully address it once and for all.Great, thank you for testing! I’ll submit a fix for it later today.
Hmm, I updated to 12.2.9 this morning, and I’m still seeing these in the logs when running jest.
@wagnermaciel Hi, I’ve just tried the new release and the bug is still here ! Take a look at the reproduction repo that I have updated to 12.2.7 I think this issue should be re-open
Thanks