question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AndrewKushnircommented, Nov 27, 2019

@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.

0reactions
angular-automatic-lock-bot[bot]commented, Jan 4, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found