Unit test
import {Goal} from '../../providers/goal/goal'; import {GoalSettingsPage} from './goal-settings'; import {Modal, Alert, NavParams, ViewController, Events} from 'ionic-angular'; import {provide,ReflectiveInjector,Component} from '@angular/core' import {FormBuilder} from '@angular/common'; import { beforeEach, beforeEachProviders, describe, expect, it, xit, TestComponentBuilder, ComponentFixture, inject, async } from '@angular/core/testing'; describe('Goal Settings', () => { it('should display header title: "Some Title"', inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { return tcb.createAsync(GoalSettingsPage).then((fixture) => { fixture.detectChanges(); var compiled = fixture.debugElement.nativeElement; expect(compiled.innerHTML).toContain('ion-title'); expect(compiled.querySelector('span')) .toHaveText('Cancel'); expect(compiled.querySelector('ion-title') .innerText).toBe('DrEvil'); }); }));
Error message
TypeError: Unable to read createAync property from undefined
Question
Pascal writes here: http://5thingsangular.imtqy.com/2016/04/11/issue-1.html that injectAsync deprecated since I createAsync like the cool dudes?
Update: the error disappeared after restarting gulp. Now I get the following:
Error: no provider for TestComponentBuilder!
Update2:
It is solved by injection in the description of the area, not the scope:
let tcb; //setup beforeEachProviders(() => [ TestComponentBuilder ]); beforeEach(inject([TestComponentBuilder], _tcb => { tcb = _tcb }));
New mistake
Error: no provider for compiler!
source share