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]
145 questions
49
votes
10 answers
Is there any way to test PHP locally without installing a server?
I'm looking for something like http://phpfiddle.org/, but completely local. I don't want to commit to installing something as complex as Apache, then PHP on top of that, just to try out code when I'm offline. Is there anything that can run PHP 5.5…
![](../../users/profiles/453435.webp)
Ben Leggiero
- 25,904
- 38
- 161
- 267
42
votes
3 answers
What is the difference between testbed.get and inject in Angular 2/Jasmine testing?
I am new to Angular 2 testing. I am trying to figure out what is the difference in using testsbed.get() and just using inject at the test level.
eg:
beforeEach(() => {
TestBed.configureTestingModule({
providers: [SomeService]
});
…
![](../../users/profiles/1026341.webp)
csaldanh
- 451
- 1
- 4
- 5
36
votes
5 answers
How override Provider in Angular 5 for only one test?
In one of my unit test files, I have to mock several times the same service with different mocks.
import { MyService } from '../services/myservice.service';
import { MockMyService1 } from '../mocks/mockmyservice1';
import { MockMyService2 } from…
![](../../users/profiles/8160877.webp)
hbaltz
- 361
- 1
- 3
- 4
31
votes
3 answers
Angular 4 - Failed: Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?)
I have referred the following link to get the answers, but I couldn't find any working solution for my scenario.
Error: (SystemJS) Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?)
Therefore, I have been trying to remove the…
![](../../users/profiles/5717747.webp)
Lakindu Gunasekara
- 3,779
- 4
- 21
- 38
24
votes
8 answers
Angular 4 Unit Tests (TestBed) extremely slow
I have some unit tests using Angular TestBed. Even if the tests are very simple, they run extremely slow (on avarage 1 test assetion per second).
Even after re-reading Angular documentation, I could not find the reason of such a bad…
![](../../users/profiles/706293.webp)
Francesco
- 7,749
- 6
- 51
- 88
22
votes
1 answer
Unit testing angular 5 component with @ViewChild
I am using angular 5.2.0. I have a child component
import { Component } from '@angular/core';
@Component({
template: `
<\div>`
})
export class ChildComponent {
public childMethod() {
...
}
}
and a parent component which…
![](../../users/profiles/976992.webp)
Jacopo Lanzoni
- 1,085
- 2
- 9
- 21
22
votes
4 answers
Angular 2: How to mock ChangeDetectorRef while unit testing
I have just started with Unit-Testing, and I have been able to mock my own services and some of Angular and Ionic as well, but no matter what I do ChangeDetectorRef stays the same.
I mean which kind of sorcery is this?
beforeEach(async(() =>
…
![](../../users/profiles/5612697.webp)
Ankit Singh
- 22,335
- 10
- 60
- 85
20
votes
2 answers
Why do I need to call detectChanges / whenStable twice?
First example
I have got the following test:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Component } from '@angular/core';
@Component({
template: '
-
yankee
- 32,900
- 12
- 87
- 147
18
votes
1 answer
Angular unit Testing : TypeError: Cannot read property 'root' of undefined
I'm working on unit testing under my Angular app.
My version of Angular is 4.0.0.
My component look like this:
component.ts:
import { GdfaClientService } from '../../../service/gdfa-client.service';
import { SharedclientService } from…
![](../../users/profiles/4957388.webp)
firasKoubaa
- 4,824
- 15
- 46
- 104
16
votes
1 answer
Modifying a component defined in TestBed.overrideComponent
We are using
TestBed.overrideComponent(CoolComponent, {
set: {
template: '
i am the fake component
',
selector: 'our-cool-component',
inputs: [ 'model' ]
}
})
to override a component.
The…![](../../users/profiles/332868.webp)
Joe Taylor
- 2,095
- 1
- 18
- 34
13
votes
2 answers
Google App Engine set up a user when using testbed
I'm using the GAE testbed service and when I run users.get_current_user() I get None i.e.
>>> import sys
>>> sys.path.append("/usr/local/google_appengine") # for Mac OS X
>>> from google.appengine.api import users
>>> from google.appengine.ext…
![](../../users/profiles/19212.webp)
Brian M. Hunt
- 71,376
- 65
- 208
- 328
10
votes
1 answer
Angular 2 - testing a component with @input used in ngOnInit lifecycle hook
Currently I am trying to test a child component which is accepting an input from the host component, and used within the ngOnInit life cycle hook like the code below.
@Component({
selector: 'my-child-component',
template:…
![](../../users/profiles/6666508.webp)
JeanPaul A.
- 3,115
- 1
- 14
- 27
9
votes
3 answers
How to implement unit tests in NativeScript using TestBed and Jasmine?
I'm setting up a NativeScript-Angular project, and would like to implement unit tests using Jasmine-Karma in order to test my components using css selectors. How can I setup a simple unit test (beyond the sample test provided on the official…
![](../../users/profiles/7470746.webp)
George S
- 183
- 1
- 13
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,…
![](../../users/profiles/3914509.webp)
Jeremy Thomas
- 4,902
- 7
- 33
- 73
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…
![](../../users/profiles/387417.webp)
Ankur Mukherjee
- 3,491
- 5
- 28
- 38