[Question | Bug] - getting sub injectable from TestingModule
See original GitHub issueHi,
When trying to get a sub injectable (for example Component
) it returns null.
For example:
// DatabaseModule
@Module({
modules: [],
components: [
SubService
]
})
export class AppModule {
}
// App Module
@Module({
modules: [
DatabaseModule
]
})
export class AppModule {
}
And then when trying to user createTestingModule
:
const module = await Test.createTestingModule({
modules: [AppModule]
}).compile();
const subService = appModule.get<SubService>(SubService);
concole.log(subModule) // null
I found this workaround:
const dbModule = appModule.select(DatabaseModule);
const subService = dbModule.get<SubService>(SubService);
concole.log(subService) // instance of SubService
So should the get
method return also nested components of other dependent modules? If so, this is a bug.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How can I unit test a component that uses the Router in ...
createComponent(MyComponent); router = TestBed.get(Router); // TestBed.inject(Router) for Angular 9+ }); it('should navigate', () => { const component ...
Read more >NestJS unit testing: A how-to guide with examples - Tom Ray
A deep dive tutorial into how to apply unit tests in NestJS with Jest, including how to mock with test doubles and other...
Read more >Component testing scenarios - Angular
There can be injectors at multiple levels, from the root injector created by the TestBed down through the component tree. The safest way...
Read more >Software Testing: 101 Top Tips, Tricks and Strategies - Stackify
Software testing is a collection of tests to determine if a software app works and will continue working. Get tips and tricks from...
Read more >TESSY 4.1 UserManual - Razorcat
In this chapter you will get to know TESSY with the help of ... Using a cross compiler for the microcontroller in question...
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 FreeTop 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
Top GitHub Comments
Fixed, will be available in the next update. Thanks again @vlio20
the
including imported ones
is a bit misleading (maybe only for me)