A testbed is a platform for experimentation of large development projects. Testbeds allow for rigorous, transparent, and replicable testing of new technologies or code in an isolated environment.
Questions tagged [testbed]
157 questions
5
votes
1 answer
When exactly is compileComponents needed?
I am migrating my component unit tests with only jest to UI tests using Testbed and jest (Before I had just unit test with component = new MyCompontent()).
I am using Angular 11.
There is one thing I do not understand about compileComponents. In the…

distante
- 6,438
- 6
- 48
- 90
5
votes
1 answer
How to mock Injector instance in Angular / Jasmine tests?
I need to test my service which is using Injector to inject services instead of constructor().
The main reason for which I use this way is the large number of services which extends my common SimpleDataService. Here are CompanyService,…

netdjw
- 5,419
- 21
- 88
- 162
5
votes
1 answer
Unable to override MAT_DIALOG_DATA provider using TestBed.overrideProvider in angular test cases
I am trying to write integration tests for a component in angular using TestBed. there is some data being injected into component for material dialog using @inject(MAT_DIALOG_DATA). I want to test two cases. One is when no data is provided and other…

Muhammad Usman
- 101
- 1
- 11
5
votes
2 answers
Angular 4 testing - [object ErrorEvent] thrown
I'm in the process of completing the test bed for my angular application. But there is an issue in the karma-jasmine testing, which throws an error
[object ErrorEvent] thrown
I updated the node_modules as a solution I found in the following…

Lakindu Gunasekara
- 4,221
- 4
- 27
- 41
5
votes
0 answers
Angular2 & TestBed: How to mock AngularFire2/observable data service?
I'm having a really hard time to try to understand how TestBed works and how to use it to mock data retrieval (via AngularFire2 i.e. observables)/pushing in an offline unit test.If someone could provide a simple example to look at it would make…

Daniel Mattsson
- 676
- 2
- 8
- 9
5
votes
3 answers
Failed to load .html in Angular 2.0.0 testing
I have a problem with TestBed in Angular 2.0.0
beforeEach( async(() => {
TestBed.configureTestingModule({
declarations: [
SomethingComponent
]
}).compileComponents(); // compile template
…

Janett Holst
- 146
- 1
- 5
4
votes
1 answer
Property 'configureTestingModule' doesn't exist on type TestBedStatic
I have updated my Angular 12 application to Angular 14 using ng update. The build was successful and can see my application running perfectly fine but my tests are failing. One of the errors I am getting is this:
Property 'configureTestingModule'…

Aayushi Jain
- 2,861
- 2
- 29
- 36
4
votes
1 answer
Angular unit testing - ignore stylesheets
I'm trying to speed up the unit tests for a fairly large non-cli Angular application and had a thought: what if I skipped the style sheets? The slowest step in running the tests (by a wide margin) is Webpack compiling the thousands of scss style…

Adam
- 71
- 5
4
votes
1 answer
Angular test: override to use template instead of templateUrl
I have a component which contains iframe. To prevent loading not existing URL from iframe in tests I would like to mock component's template. I thought I could do it using TestBed.overrideComponent() but it has no effect. When test runs I can see…

Martin Nuc
- 5,604
- 2
- 42
- 48
4
votes
5 answers
Angular 6 Error: Cannot make XHRs from within a fake async test. Request URL: https://mlj0xk2yy.com/latest/static/videos
Can you tell me how to solve this issue?
login.component.spec.ts
const mockModel = {
url: 'login',
model: {
handle: 'test@test.com',
password: '123456789'
}
}
export class…

Sampath
- 63,341
- 64
- 307
- 441
4
votes
1 answer
Argument of type "emit" is not assignable to parameter of type 'never'
I need to test a component in Angular which has only one method and certain @Input and @Output properties-
updateColumns(eventValue: ManagedColumns) {
this.applyColumnChanges.emit(eventValue);
}
There is another component that has method…

a p
- 1,121
- 6
- 26
- 51
4
votes
3 answers
How to write test for Resolve
I want to write test for my service ,
I want to sure parameter is send ok .how can i test that
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import {…

ali akbar azizkhani
- 2,213
- 5
- 31
- 48
4
votes
0 answers
Testing Angular 4 service without mocking backend
I need to test an Angular 4 service without mock the backend, but got no success.
My beforeEach is as follow:
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { RouterStub } from './test-utils/router-stub';
import {…

Jim Bruno Goldberg
- 41
- 2
4
votes
1 answer
Setting up TDD in ionic2
I've followed Joshua Moroney's tutorial on Ionic2 and TDD, but have got stuck when trying to debug errors as they occur.
The core example is this one:
import { TestBed, ComponentFixture, async } from '@angular/core/testing';
import { By } from…

andylockran
- 181
- 1
- 9
4
votes
1 answer
angular2/jasmine injected mock service not calling spies
Attempting to unit test an angular2 app using jasmine, but when I try to inject service, the spies don't pick up on injected calls.
Test suite:
import { TestBed, inject, tick, fakeAsync, ComponentFixture } from '@angular/core/testing';
import { By }…

aurora.lane
- 43
- 1
- 4