55 questions
Advice
1
vote
1
replies
101
views
Angular: Vitest vs Jasmine/Karma
I am a bit confused with the Angular testing landscape. I have seen that Vitest will become the new default, replacing Karma. The question I then have is what about Jasmine. Does Vitest replace only ...
0
votes
1
answer
49
views
Global propery in JSDOM not being set in integration test (angular-testing-library)
I'm not able to set up my testing-library integration tests so they recognize the global interface with the third party static methods from my component library Preline UI
I'm using JSDOM and angular-...
0
votes
1
answer
95
views
Angular -Access route param require input in tests when using using with component input binding
I am using Angular 18 with Angular testing library: my issues is that I am able access route param as required input signal. However when I run the tests that depends on this input it's complaining ...
0
votes
1
answer
645
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": {
...
"...
0
votes
1
answer
1k
views
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 ...
5
votes
1
answer
2k
views
Angular 14 + Jest - typescript_1.default.canHaveDecorators is not a function
After configuring Jest with Angular 14, I'm getting this error:
Test suite failed to run
TypeError: typescript_1.default.canHaveDecorators is not a function
at TypeScriptReflectionHost....
0
votes
1
answer
81
views
how to get the property of behaivourSubject type property of a service ?, angular testing
I have a service like
export class TestService {
public props: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
props$ = this.props.asObservable();
test(){
}
}
...
1
vote
1
answer
101
views
Error in tests with Angular 6 and Jest - TypeError: testing.TestBed.inject is not a function
When running the tests on my project when trying to render the component, the tests fail with the following error:
TypeError: testing.TestBed.inject is not a function
This is the test component:
...
0
votes
1
answer
2k
views
cannot read properties of undefined reading subscribe testing jasmine angular
Hi I trying to test http request but , when I call a function in the ngOnInit it show me that message "cannot read properties of undefined"
can somebody help me?
this is my test
it('xxxx',...
1
vote
1
answer
2k
views
How can I test if a @output emit a value?
I have a component that emit a value when call to a function,
how can I test if the @output emit a value ?
this is my function
@Output() emitDetail = new EventEmitter();
emitDetailFn() {
this....
1
vote
0
answers
292
views
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, {
...
1
vote
1
answer
2k
views
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 ...
1
vote
1
answer
2k
views
Testing Angular Output without spying on the component instance
Let's suppose I have the following component:
@Component({
selector: 'app-dumb',
template: '<button (click)="increment()">Increment</button>'
})
export class ...
0
votes
1
answer
24
views
How to test a service subcription to a subject from another service
I have the following services:
@Injectable({
providedIn: 'root'
})
export class Service1 {
dataHasChanged = new Subject();
private data1;
private data2;
constructor() {}
getData() {
...
4
votes
2
answers
4k
views
How to test Custom Elements / Web Components with Testing-Library, Jest and JSDOM?
I am trying to test an Angular app with testing-library/angular@11 and [email protected] which uses custom-elements quite heavily.
Unfortunately I am not quite sure if testing-library/JSDOM/Jest just don't ...
2
votes
1
answer
1k
views
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 {...
1
vote
1
answer
513
views
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, ...
1
vote
1
answer
1k
views
How to test ng-select using Angular testing library?
I have the below list of companies populated in an ng-select:
<div class="input-group">
<ng-select role="company" id="company" class="form-control" ...
0
votes
1
answer
325
views
Angular 10 test with @testing-library/angular (page) attribute method on mat-paginator
I have the <mat-paginator> element working fine, I just want to know how the heck to I test the getPaginatorData method for the (page) attribute with the @testing-library/angular library?
<...
0
votes
1
answer
2k
views
Unit test case for mat-menu with jest and @testing-library/angular
I have a Component that uses mat-menu from Angular Material UI. When I call fireEvent.click(), I get an error: TestingLibraryElementError: Unable to find role="menu" in console.
This is my ...
2
votes
0
answers
168
views
Angular 11 can't achieve to test if an url was called
I had a problem with angular testing. I want to detect when an url change on a button click. I followed a lot of similar issues on stack but can't achieve to my goal since 1 one week :/
Explanation
...
27
votes
3
answers
16k
views
Stop huge error output from testing-library
I love testing-library, have used it a lot in a React project, and I'm trying to use it in an Angular project now - but I've always struggled with the enormous error output, including the HTML text of ...
7
votes
0
answers
812
views
How to get the value of a select when using ngValue in Angular unit tests
In my Angular app I have a <select> bound to a reactive form like the following:
<form [formGroup]="myForm">
<select formControlName="myControlName" id="my-...
7
votes
1
answer
2k
views
angular-testing-library: getByRole query works only with hidden: true option
I am just trying out this library and seem to be unable to access elements by their ARIA role.
I use angular 10.0.6, jest 26.2.1 together with jest-preset-angular 8.2.1 and @testing-library/angular 10....
0
votes
0
answers
105
views
Writing tests with testing-library depends on implementation details of my UI library
I am using @testing-library to test my React project which uses Material-UI as it's main UI library. As @testing-library suggests, it's main philosophy is to test the application in the exact same way ...