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
8
votes
3 answers
Angular 9 i18n migration - failing tests
I am upgrading from Angular 8.0 to Angular 9.1.1. With a little bit of work, everything builds and runs fine.
I ran into the localization issue https://angular.io/guide/migration-localize and followed these instructions - this allowed my project…

nbpeth
- 2,967
- 4
- 24
- 34
8
votes
3 answers
Ionic 4: Creating mock storage
I am trying to use Testbed in a new Angular 7 / Ionic 4 app but cannot run any tests because my components depend on an Ionic native plugin, storage.
app.component.spec.ts
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import {TestBed,…

Jeremy Thomas
- 6,240
- 9
- 47
- 92
8
votes
1 answer
Async beforeEach finished before/after each test unit(it)
I am using Angular 6 and I have one concern regarding every test which I have seen so far.
Here's a simple test of simple component which is generated by cli.
describe('CompComponent', () => {
let component: CompComponent;
let fixture:…

Brk
- 1,247
- 2
- 23
- 55
8
votes
3 answers
angular 5 testing - configure testbed globally
I want to import certain modules for all testing suits such as ngrx Store, ngx translate or httpClientModule in an angular-cli@1.50 project with angular 5.
in the generated test.ts I have added a test.configureTestingModule
const testBed: TestBed =…

Han Che
- 8,239
- 19
- 70
- 116
8
votes
2 answers
Angular2 @Viewchild unit test
I have a component like this:
export class ParentComponent implements OnInit, OnDestroy {
@ViewChild(ChildComponent) childComponent: ChildComponent;
}
which is using the childComponent to make a call, let's say like…

Ankur Mukherjee
- 3,777
- 5
- 32
- 39
8
votes
2 answers
Angular 2 TestBed with mocks
I am trying to test a component which uses another service. And I want to isolate the component by providing a mock for the service. Before RC5 I can simply use addproviders which is now deprecated and will be removed by the next RC. Instead I have…

LonsomeHell
- 573
- 1
- 7
- 29
7
votes
1 answer
Override component in another module in Angular TestBed
I'm writing TestBed unit tests.
There is a certain component, which is a child of the component-under-test. That child component causes errors while the test is running. That child component is not relevant to the test itself; it's just causing…

Ania
- 327
- 3
- 12
7
votes
2 answers
angular Testbed overrideModule not working
When using the following configuration for a test fixture, I get complaints that the tag cannot be found. Substituting the MockSelectionToolComponent directly in AppModule works fine, so must be something else...
// Add the imported module to the…

jenson-button-event
- 18,101
- 11
- 89
- 155
7
votes
2 answers
Testing with TestBed: no Provider for StatusBar error
I've read the article about testing Ionic2 projects with TestBed and I've got the trouble when I'm trying to repeat example from article in my environment. When I try to start tests on Step 3 I have the error "No provider for StatusBar".
Probably…

NobbyNobbs
- 1,341
- 1
- 11
- 17
7
votes
1 answer
error with angular2 testing component with Testbed
trying to learn this testing utility TestBed in angular-2 with a simple example and have hit my first blocker. google or SO search didn't yield any matching example,
so, I have a very basic component header as below -
import { Component } from…

tiwarib
- 441
- 6
- 17
7
votes
2 answers
OverrideComponent with TestBed
I have MainComponent that uses ChildComponentA as a @ViewChild. MainComponent is calling a method on ChildComponentA.
I want to write an unit test case mocking ChildComponentA. How can I do this using TestBed (in Angular 2 RC5)?
Before I used to use…

Kashyap
- 178
- 1
- 2
- 11
7
votes
2 answers
Are unittest base classes good practice? (python/webapp2)
I'm rather new to unit-testing and am trying to feel out the best practices for the thing. I've seen several questions on here relating to unit-test inheriting a base class that itself contains several tests, for example:
class…

Quentin Donnellan
- 2,687
- 1
- 18
- 24
6
votes
2 answers
Unit Testing : No provider for "InterceptableStoreFactory" even if added to "providers"
I'm working on unit tests within my Angular app , i'm using TestBed approach ,
I'm testing components , so each spec file looks like this
import...
describe('AppComponent', () => {
// Importing dependecies
beforeEach(async(() => {
…

firasKoubaa
- 6,439
- 25
- 79
- 148
6
votes
1 answer
Angular TestBed fails with Webpack, Karma/Jasmine
I tried to use Angular TestBed as described on angular.io website to test a simple component, but I get errors like: TypeError: undefined is not an object (evaluating 'ProxyZoneSpec.assertPresent') and 404 as it cannot load the external component…

Francesco
- 9,947
- 7
- 67
- 110
6
votes
1 answer
Using Angular2 TestBed to Mock a service with a non-concrete class interface parameter
I have a component that I am trying to setup and test using TestBed.
This component contains one class that has a parameter in the constructor that is an interface, not a concrete class. This interface is satisfied by whatever class I choose to use…

Kim Gentes
- 1,496
- 1
- 18
- 38