Ivy TestBed should throw descriptive errors when override methods are used with incompatible types
See original GitHub issueπ bug report
Affected Package
The issue is caused by package "@angular/core": "9.0.0-rc.3",Description
When I use TestBed.overrideComponent to override some services with their mocks, the tests start failing with the following error:
Cannot read property 'templateUrl' of null
The code snippet thatβs causing the error:
TestBed.overrideComponent(SomeDirective, {
set: { providers: [{ provide: SomeService, useClass: MockSomeService }] },
});
π¬ Minimal Reproduction
https://github.com/Shijir/shiny-ivy-app-test-fail
π₯ Exception or Error
Failed: Uncaught (in promise): TypeError: Cannot read property 'templateUrl' of null
TypeError: Cannot read property 'templateUrl' of null
at componentNeedsResolution (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:21097:1)
at maybeQueueResolutionOfComponentResources (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:21080:1)
at compileComponent (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:39395:1)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/testing.js:1941:30
at Set.forEach (<anonymous>)
at R3TestBedCompiler.compileTypesSync (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/testing.js:1932:1)
at R3TestBedCompiler.<anonymous> (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/testing.js:1827:1)
at Generator.next (<anonymous>)
at http://localhost:9876/_karma_webpack_/node_modules/tslib/tslib.es6.js:73:1
at new ZoneAwarePromise (http://localhost:9876/_karma_webpack_/node_modules/zone.js/dist/zone-evergreen.js:872:1)
π Your Environment
Angular Version:
@angular/core": "9.0.0-rc.3
Anything else relevant?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
@angular/http | Yarn - Package Manager
Any TypeScript/JavaScript code which relied on the names of keyframes rules will no longer match. ... define keyframes rules programmatically in code. compiler-Β ......
Read more >SCJP - override method with exception handling raises a ...
It is deciding whether a checked exception can be thrown based solely on the type of the variable referencing the Dog2.
Read more >Template type checking - Angular
Just as TypeScript catches type errors in your code, Angular checks the expressions and bindings within the templates of your application and can...
Read more >Java Method Overriding - Learn its Importance and Rules with ...
A compile-time error occurs if an exception occurs in a parent class. The overriding methods of the child class should not throw any...
Read more >Cannot override method to avoid name clash error if sub-class ...
Now an error "Name clash: The method myMethod() of type Extender has the same ... must return a type that's both a subclass...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Shijir, thanks for the update. Adding more descriptive error messages for the cases like this one makes sense, Iβll work on a PR to do that. Note: I will also change the title of the ticket to reflect that. 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.