Questions tagged [testbed]

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.

145 questions
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
  • 136
  • 1
  • 5
4
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
  • 3,842
  • 11
  • 50
  • 101
4
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…
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
  • 4
4
votes
1 answer

Async beforeEach finished before/after each test unit(it)

Hey I am new to tests in angular 6(aka angular) and I have one concern regrading every test which I have seen so far. Let's first look at a simple test of simple component(which is generated by cli) describe('CompComponent', () => { let component:…
Brk
  • 1,155
  • 18
  • 46
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…
infinite
  • 553
  • 1
  • 15
  • 31
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 {…
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
  • 141
  • 1
  • 8
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
4
votes
1 answer

Angular2 testing with TestBed getting Zone undefined Error

I've been working off the Angular tutorial https://angular.io/docs/ts/latest/guide/testing.html to build my first unit tests. I am able to get everything to work until I get to the TestBed example. When I add TestBed into the mix I get 'Uncaught…
Tye2545
  • 191
  • 2
  • 8
4
votes
2 answers

Testbed stub for Google App Engine 'search'

I am trying to test Google App Engine's new full text search functionality in Python with the development appserver. Is there a stub for the search that allows one to test it with the testbed local unit testing? The following is example code that…
Brian M. Hunt
  • 71,376
  • 65
  • 208
  • 328
3
votes
1 answer

Regular Expressions Testbed

I am currently attempting to implement a regular expression engine. (Yes, for fun. Go fig.) I am working from this site for general algorithmic approach: http://swtch.com/~rsc/regexp/regexp1.html My question for you all is: do you know of a…
ibiwan
  • 88
  • 5
3
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
  • 4,507
  • 3
  • 29
  • 63
3
votes
1 answer

Angular9 debugElement.classes['my-class'] now returns undefined

I'm updating a repo that used to use Angular 8. In a test, using TestBed, I'm checking if a class exists using: fixture.debugElement.classes['my-class'].toBe(false) After updating to Angular 9, this test no longer works, as the expression no longer…
3
votes
1 answer

Angular:Why NO_ERRORS_SCHEMA does not work for attribute?

I'm writing my first Angular tests and having a problem here. I'm testing a component, which has a custom attribute in it ... Official documentation says The NO_ERRORS_SCHEMA tells the Angular…
Lunin Roman
  • 2,152
  • 4
  • 16
  • 43
1 2
3
9 10