Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [angular-test]

Questions about testing Angular code, addressing either specific issues ("why is this test failing"), test flows ("how to test this async call of my component") or test setup ("how do I mock router in this component test"), integration tests ("how to bypass a proxy to my backend in this angular test"), or possibly test-related questions, such as ("Why does this component work and the test is failing?").

0 votes
1 answer
42 views

Angular tests with Jest: How to inject HttpClient: Can't resolve all parameters for xxxx

I'm moving my tests from jasmine/karma to Jest. I'm struggling to inject HttpClient and its testing controller. I'm following https://angular.io/guide/http-test-requests and I get this dummy test: ...
J4N's user avatar
  • 20.3k
-1 votes
0 answers
13 views

How to spy on public field with Jest+jest-auto-spies

I've this Angular service that I'm trying to mock: @Injectable({ providedIn: 'root', }) export class NotificationsService { private _notifications = new Subject<Notification>(); public ...
J4N's user avatar
  • 20.3k
1 vote
4 answers
100 views

Angular 17+ testing services with signals and effects

I am not very experienced with Angular signals, especially with services with signals and effects. Basically, I have a service A which exposes a public method that sets/updates a private signal in the ...
Nenad's user avatar
  • 13
0 votes
0 answers
23 views

Unable to query or access ng-template contents inside the spec.ts file

I am not able to test a ng-template data in my component which is rendered inside a mat-dialog pop-up.FYI I used fixture.detectChanges() also. When i try to log the templateRef in spec.ts getting the ...
JOYEL GEORGE's user avatar
0 votes
0 answers
10 views

expect MatSnackBar 'Open' function to be called is not working when Testing

I'm trying to test a function using Jest/Angular 18 Component: export class AppComponent { ... constructor(private authService: AuthService, private snackbar: MatSnackBar, private settingService: ...
A. O.'s user avatar
  • 36
0 votes
1 answer
49 views

Angular Circular dependency problem in test case

i have a component that have circular dependency and followed this article everything is working but failed test case which i unable to solve this @Component({ selector: 'my-list', templateUrl:...
U rock's user avatar
  • 767
0 votes
0 answers
24 views

proper way to inject angular DOCUMENT token in test case

i am struggling to have an issue with injecting DOCUMENT in my test service i have a service like this export class ClientValueExtractorService { constructor( @Inject(DOCUMENT) private ...
U rock's user avatar
  • 767
0 votes
0 answers
28 views

How to unit test a keyDown directive on input with Angular?

I tried many variations based on answers here but none worked, the KeyboardEvent never sets value on the input. How can I simulate a user typing characters? Unit test: @Component({ selector: 'app-...
ymoreau's user avatar
  • 3,696
0 votes
1 answer
74 views

Angular Unit testing: How to pass multiple files through include while running ng test from CLI?

I am using ng test to run my unit tests. I have a scenario where I need to test mutliple spec files which are in different paths. I am able to do this using angular.json "test": { ... "...
Naveen kumar S's user avatar
0 votes
0 answers
166 views

Facing issue console.error Error: Not implemented: navigation (except hash changes) while runing jest test cases

public saveCSV(fileName: string, csvData: string): Observable<boolean> { const exportedFilenmae = fileName + '.csv'; const blob = new Blob([csvData], { type: 'text/csv;charset=utf-8;' }); const ...
Baba Sri Harsha's user avatar
0 votes
2 answers
69 views

Jasmine/Karma error "TypeError: Cannot read properties of undefined (reading 'events')" error after putting routerLink on Angular template

I am trying to make some tests in my Angular app, but when I add this line with routerLink, the tests gives me errors: <a class="nav-link" routerLink="../loja-lista" role="...
Mauro Gabriel's user avatar
0 votes
1 answer
45 views

how to mock a standalone directive?

Anchor tags from the table cells are attached with a [routerLink] directive. My aim is to test the table. I would like to mock the directive. How can I do this? More detailed question: how to provide ...
Kianni's user avatar
  • 68
0 votes
1 answer
32 views

Unit testing Angular CLI - Karma/jasmine 4.3.5 jasmine component issue

For some reason I cannot make the mock data work. So it can create component NullInjectorError: R3InjectorError(DynamicTestModule)[ListingsService -> AuthService -> MessageService -> ...
Flamme97's user avatar
0 votes
1 answer
31 views

Why there is an error when I want to check expected result after some time in Jasmine&Karma in Angular?

I want to test this component describe('Test for check if window dissapeard', () => { let component: DismissMockedComponent; let fixture: ComponentFixture<DismissMockedComponent>; ...
ruddnisrus's user avatar
0 votes
1 answer
191 views

TypeError: Cannot read properties of undefined (reading 'reRenderOnLangChange')

In my Angular project, my unit tests fail with the following error: TypeError: Cannot read properties of undefined (reading 'reRenderOnLangChange') at shouldListenToLangChanges (node_modules/@ngneat/...
Francesco Borzi's user avatar

15 30 50 per page
1
2 3 4 5
50