Skip to content

Mocking standalone with spectator. #2990

Answered by satanTime
grosch asked this question in Q&A
Discussion options

You must be logged in to vote

it works the next way MockBuilder(ThingsToKeepAsItIsForTesting, ThingsToMockForTesting), starting the version 14 there is an additional behavior for ThingsToKeepAsItIsForTesting, if it's a standalone declaration, then MockBuilder will mock all imports and redeclare the decoration:

so instead of having

@Component({
    selector: 'app-foo',
    standalone: true,
    imports: [HeaderComponent],
    template: '<app-header></app-header>'
})
``

during testing, it will be 

```ts
@Component({
    selector: 'app-foo',
    standalone: true,
    imports: [MockComponent(HeaderComponent)], // <- MockComponent
    template: '<app-header></app-header>'
})

Because you are testing ExampleComponent, you …

Replies: 5 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@satanTime
Comment options

Answer selected by satanTime
Comment options

You must be logged in to vote
2 replies
@satanTime
Comment options

@satanTime
Comment options

Comment options

You must be logged in to vote
1 reply
@satanTime
Comment options

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
None yet
2 participants
Converted from issue

This discussion was converted from issue #2989 on July 03, 2022 09:57.