Questions tagged [angular-testing-library]

51 questions
1
vote
1 answer

How can I test if a method was called with toHaveBeenCalled ? angular

I have a function that update a variable, but in the coverage its show me that function as if I had not tried it. How can I test if a function was called ? This is my function changePage(event) { this.currentPages = event.currentPage - 1; …
1
vote
0 answers

How to Retrive the data value from `MAT_DIALOG_DATA` with angular testing

I am retrive the passing value to MAT_DIALOG_DATA any one help me? spec.ts: test('should check component data', async () => { const { fixture } = await render(PrintPopupComponent, { detectChanges: true, imports: [ …
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
1
vote
1 answer

Angular Ag-Grid row group empty render when querying DOM elements with angular-testing-library

I have an ag-grid that contains different columns and column groups, as well as row groups. I am trying to test the DOM elements displayed in the row group using Jest and Angular Testing Library. The problem I am having is that the DOM renderer for…
1
vote
3 answers

ng mocks library to test form component ( template driven form )

I have been going through a ton of documentations including their own ng-mocks library here . I am relatively new to this library. PS: I know other libraries like spectator to do this, or using plain jasmine / jest, but i was trying the same using…
1
vote
1 answer

Testing Angular Output without spying on the component instance

Let's suppose I have the following component: @Component({ selector: 'app-dumb', template: '' }) export class DumbComponent { @Output() onIncrement = new EventEmitter(); …
1
vote
0 answers

Input type of date is not working on testing library Angular , throwing error of not found label

im trying to do this test oover an input of type date in angular using Testing Library. But keep receiving this error: TestingLibraryElementError: Unable to find a label with the text of: date-input-label My template would be kind…
Enrique GF
  • 1,215
  • 3
  • 16
  • 35
1
vote
1 answer

AG-Grid gridReady not being called on tests with Angular and Jest

The gridReady method of the Angular AG Grid is not being called in the Jest tests. Do you know why? Here you have my test code: import {TestBed} from "@angular/core/testing"; import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from…
Jöcker
  • 5,281
  • 2
  • 38
  • 44
1
vote
1 answer

Angular-testing-library - my test is not failing when expect wrong values

I am using angular-testing-library for my component testing. when expect for fail, after setting the value, my test case not failing. any one help me? (title,newTitle - @inputs) import { render, screen } from '@testing-library/angular'; import…
user2024080
  • 1
  • 14
  • 56
  • 96
1
vote
1 answer

How to test ng-select using Angular testing library?

I have the below list of companies populated in an ng-select:
avdeveloper
  • 449
  • 6
  • 30
1
vote
0 answers

TypeError: Cannot read property 'paramMap' of undefined while running my angular test

I am getting an error when running my angular 2 tests. the following is the error i receive. CreateFlightComponent should send a request to create a flight TypeError: Cannot read property 'paramMap' of undefined TypeError: Cannot read property…
Starbucks Admin
  • 585
  • 1
  • 8
  • 21
1
vote
1 answer

How do I rerender an Angular attribute directive using testing-library

Given this very trivial attribute directive where all it does is putting text from input into innerText import { Directive, ElementRef, Input } from '@angular/core'; @Directive({ selector: '[appTrivial]', }) export class TrivialDirective { …
user776686
  • 7,933
  • 14
  • 71
  • 124
1
vote
1 answer

Using Jasmine-DOM in Angular project

I have an Angular 10 CLI project (v10.1.2). I've installed @testing-library/angular@10.0.2, and I want the nice matchers like .toBeInTheDocument(), but as I'm using Karma to run Jasmine (configured via Angular) and Typescript, I'm not sure how to…
1
vote
0 answers

Can not find module 'ngx-store' from service.ts

currently I am running on Angular 9 ,while I am testing My Component using Jest, I am getting an error like "Can not find module 'ngx-store' from service.ts" and the code showing me which is wrong in service file (cartService). import…
0
votes
1 answer

BDD based testing framework/library for testing frontend behaviour in Angular?

First of all, I looked at another question, BDD framework for the frontend. The question has gone on entirely different direction. BDD is not about Cucumber or Plain english tests names. (Jasmine/Mocha and most others achieve how to describe the…
0
votes
1 answer

testing an Angular component with a ngrx store, not causing actions to be triggered

I have a few angular components that I want to test and make sure that they are working. The idea of the component in it's simplest form is to list datapoints. Each of these datapoints should be removable via and API. So the flow as it is setup…
munHunger
  • 2,572
  • 5
  • 34
  • 63