2017-01-02 11 views
0

私は角度2のテストを学習していますが、現時点では意味をなさないエラーが発生しています。現在の仕様がないときに 'expect'が使用されました

'expect' was used when there was no current spec,

テスト:

import {ExperimentsComponent} from "./experiments.component"; 
import {StateService} from "../common/state.service"; 
import {ExperimentsService} from "../common/experiments.service"; 

describe('experiments.component title and body should be correct',() => { 

    let stateService = StateService; 
    let experimentService = ExperimentsService; 

    let app = new ExperimentsComponent(new stateService, new experimentService); 

    expect(app.title).toBe('Experiments Page'); 
    expect(app.body).toBe('This is the about experiments body'); 

}); 

コンポーネント:

import {Component, OnInit} from "@angular/core"; 
import {Experiment} from "../common/experiment.model"; 
import {ExperimentsService} from "../common/experiments.service"; 
import {StateService} from "../common/state.service"; 


@Component({ 
    selector: 'experiments', 
    template: require('./experiments.component.html'), 

}) 
export class ExperimentsComponent implements OnInit { 
    title: string = 'Experiments Page'; 
    body: string = 'This is the about experiments body'; 
    message: string; 
    experiments: Experiment[]; 

    constructor(private _stateService: StateService, 
       private _experimentsService: ExperimentsService) { 
    } 

    ngOnInit() { 
     this.experiments = this._experimentsService.getExperiments(); 
     this.message = this._stateService.getMessage(); 
    } 

    updateMessage(m: string): void { 
     this._stateService.setMessage(m); 
    } 
} 

結局私は練習アプリですべての機能をテストしたいです。しかし、現在のところ、私は角度cliによって生成されたテストをパスするだけです。

私がドキュメントから読んだところから、私がやっていることが正しいように見えました。

答えて

1

expect()文このようなit()ステートメント内で発生:

describe('ExperimentsComponent',() => { 
... 
    it('should be created',() => { 
    expect(component).toBeTruthy(); 
    }); 
... 
} 

エラーが読み取ることができる方法は次のとおりです。

ExperimentsComponentを作成して作成する必要がありましたあなたは持っているように見えますdescribeitのパラメータが混乱する

関連する問題