Questions tagged [ng-mocks]

40 questions
1
vote
1 answer

Angular component test with spectator logs "can't bind to input" warnings for mocked child component

I'm facing an issue mocking a child component in an Angular 9 component test using @ngneat/spectator. The mocking and passing of the mock work fine, but it throws warnings in the logs for the inputs (even though they are valid). The simplified…
bbop99
  • 1,625
  • 1
  • 11
  • 25
1
vote
0 answers

Error testing any component with Ionic ion-infinite-scroll as child (Ionic 4)

First off, this isn't a breaking issue, but I do not like the fact that running my unit tests is presenting an error. So anyways, if you create a page/component with Ionic and use the ion-infinite-scroll component, and then proceed to unit test this…
SpellChucker
  • 450
  • 5
  • 18
0
votes
1 answer

Angular CDK Overlay not appearing in Jest snapshot

I'm writing an integration test for an Angular Component / module using Jest and ngMocks. One of the functions I'm testing uses the CDK overlay to display some important inputs that I want to select to do further steps. However, the CDK overlay…
Ewan
  • 378
  • 3
  • 14
0
votes
1 answer

NgMocks: cannot write test for canActivate guard

I'm implementing tests for a simple canActivate guard. See below: // guard export const hasGraphResultsCanActiveGuard: CanActivateFn = ( route: ActivatedRouteSnapshot, routerState: RouterStateSnapshot ) => { return inject(Store) …
JDillon522
  • 19,046
  • 15
  • 47
  • 81
0
votes
0 answers

Angular: Test code in a module's constructor with NgMocks

I have a simple notifications module that uses material's snack bar while listening on an Ngrx Selector. I dont have any components and work is done in the module's constructor so the consumer only needs to import the module and then dispatch a new…
JDillon522
  • 19,046
  • 15
  • 47
  • 81
0
votes
2 answers

Cannot trigger click event undefined element

I need to test click event on mat-table row. Below is my mat-table code
0
votes
1 answer

How to use Jest to write a unit test for canActivate Angular guards

I want to use Jest instead of jasmine to write a unit test for my angular app. a jest unit test for guard servcie for the mehtod canActivate. My question is, how to mock the router? describe('TestServiceGuard', () => { let service:…
user1938143
  • 1,022
  • 2
  • 22
  • 46
0
votes
0 answers

Unit test lazy loaded stand alone component in angular 14 using import() with no module

Can the following link that describe Dynamic component rendering be unit tested. based on this link Dynamic component rendering https://codereacter.medium.com/angular-advanced-features-and-tips-you-may-not-know-about-cae3b8527184
shah11
  • 11
  • 2
0
votes
1 answer

Auto-Mock Angular Components

Problem When testing Angular Components, I often stumble upon the following error message: 'NG0304: 'app-chip' is not a known element: 1. If 'app-chip' is an Angular component, then verify that it is part of this module. 2. If 'app-chip' is a Web…
Florian Gössele
  • 4,376
  • 7
  • 25
  • 49
-1
votes
1 answer

Difference of mock() vs. provide() in ng-mocks

What is the difference between https://ng-mocks.sudo.eu/api/MockBuilder#mock MockBuilder(TargetService, TargetModule) .mock(Service2, { trigger: () => 'mock2' }) and https://ng-mocks.sudo.eu/api/MockBuilder#provide MockBuilder(TargetService,…
krema
  • 939
  • 7
  • 20
1 2
3