Skip to content
Discussion options

You must be logged in to vote

Hi there,

you are very close.

Because ENVIRONMENT_TOKEN is a dependency, it should be provided in MockBuilder:

beforeAll(() => MockBuilder(AppComponent, [ENVIRONMENT_TOKEN]));

Otherwise ng-mocks cannot detect it, because of inject it's a runtime dependency, whereas before with @Inject it was a declaration dependency, which could be detected without executing code.

The correct version of your test: https://codesandbox.io/s/silly-wescoff-xkg4ri?file=/src/test.spec.ts:641-658

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@c-harding
Comment options

Answer selected by satanTime
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
4 participants
Converted from issue

This discussion was converted from issue #4973 on March 05, 2023 13:54.