Skip to content

Commit 8512af1

Browse files
authored
docs: ng-mocks example for standalone components (#1095)
1 parent 7fab0dc commit 8512af1

File tree

1 file changed

+4
-3
lines changed
  • docs/angular-testing-library

1 file changed

+4
-3
lines changed

docs/angular-testing-library/faq.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ As you write your tests, keep in mind:
3131

3232
In general, you should avoid mocking out components (see
3333
[the Guiding Principles section](guiding-principles.mdx)). However, if you need
34-
to, then try to use [ng-mocks](https://ng-mocks.sudo.eu/).
34+
to, then try to use [ng-mocks](https://ng-mocks.sudo.eu/) and its [`MockBuilder`](https://ng-mocks.sudo.eu/extra/with-3rd-party#testing-libraryangular-and-mockbuilder).
3535

3636
```typescript
3737
import {Component, NgModule} from '@angular/core'
3838
import {render, screen} from '@testing-library/angular'
39-
import {ngMocks} from 'ng-mocks'
39+
import {MockBuilder} from 'ng-mocks'
4040

4141
@Component({
4242
selector: 'app-parent-component',
@@ -57,7 +57,8 @@ export class AppModule {}
5757

5858
describe('ParentComponent', () => {
5959
it('should not render ChildComponent when shallow rendering', async () => {
60-
const dependencies = ngMocks.guts(null, AppModule, ParentComponent)
60+
// all imports, declarations and exports of AppModule will be mocked.
61+
const dependencies = MockBuilder(ParentComponent, AppModule).build();
6162

6263
await render(ParentComponent, dependencies)
6364

0 commit comments

Comments
 (0)