lundi 4 juillet 2016

Angular2: "TypeError: Cannot read property 'createAsync' of undefined"

The 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');

        });
  }));

The Error Message

TypeError: Cannot read property 'createAsync' of undefined

The Question

Pascal writes here: http://ift.tt/29rx1my that injectAsync is deprecated, so how do I createAsync like the cool dudes do?

Update: error disappeared after restart of gulp. Now I get this:

Error: No provider for TestComponentBuilder!

Aucun commentaire:

Enregistrer un commentaire