TestBed passes even without any declarations in NG9 and NG10
See original GitHub issue🐞 bug report
Affected Package
The issue seems to be in @angular/core/testing
or the new bazel/ivy build rig.
Is this a regression?
Yes, this behavior worked in Angular 8. Angular 8 reports the following error…
Error: Illegal state: Could not load the summary for directive AppComponent.
error properties: Object({ ngSyntaxError: true })
Description
Angular’s TestBed no longer works in any kind of logical way.
You can completely remove calls to TestBed.configureTestingModule
and the unit tests still run, compile, and succeed. This is totally unexpected, as you are supposed to be able to pass declarations or mock declarations for every token. It’s now completely unclear what environment is being used when the test runs, whereas before you explicitly provided every dependency.
🔬 Minimal Reproduction
https://github.com/smzelek/minimal-repro-ng10-testbed-bug Simply run the unit tests:
- npm run test
Notice that all 3 tests pass, the component is successfully rendered in the Karma runner window, variable templating succeeds…, even though there is no TestBed configuration at all.
🌍 Your Environment
Angular Version:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 10.0.7
Node: 12.18.2
OS: win32 x64
Angular: 10.0.12
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.1000.7
@angular-devkit/build-angular 0.1000.7
@angular-devkit/build-optimizer 0.1000.7
@angular-devkit/build-webpack 0.1000.7
@angular-devkit/core 10.0.7
@angular-devkit/schematics 10.0.7
@angular/cli 10.0.7
@ngtools/webpack 10.0.7
@schematics/angular 10.0.7
@schematics/update 0.1000.7
rxjs 6.5.5
typescript 3.9.7
webpack 4.43.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Hi @ahnpnl,
Components might be pre-compiled (in AOT mode) before tests are executed by TestBed, in which case TestBed uses compiled components and only re-compile them (in JIT mode) when there is an override which can not be applied as a patch (i.e. without triggering a re-compilation), for example if a template is overwritten in a test. In View Engine’s version of TestBed components were always re-compiled for each set of tests.
Looking at the issue that you refer to (thymikee/jest-preset-angular#409), I think it might make sense to open a new ticket and describe questions/issues that you have, so that the team can provide some additional insights.
Thank you.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.