期待在茉莉花不完全工作

我正在用量angular器进行jasinetesting,我不确定期望如何工作。 我期望茉莉花给我一个失败,因为我显然有一个失败的期望。 它并没有。

我使用使用Jasmine2的grunt-protractor-runner 1.2.1。

我有这个testing用例:

var validateObject = function(object) { expect('1.0').toEqual('1.0'); //no error //expect('1.1').toEqual('1.0'); //error console.log(object['property']); //1.0 console.log(object['property'] === '1.0'); //true console.log(typeof object['property']); //string /*PROBLEM STARTS HERE*/ expect(object['property']).toEqual('1.0'); //no error expect(object['property']).toEqual('1.1'); //no error }; var readSomething = function(done) { fs.createReadStream('folder + fileName') .pipe(operation.Parse()) .on('entry', function(file) { validateObject(file); .on('end', function(){ done(); }); }; describe('test this', function () { it("stuff", function (done) { /*lots of stuff happening*/ expect('asd').toEqual('asd'); //no error //expect('asd').toEqual('asds'); //error readSomething(done); }); }); 

任何想法,我在这里失踪? 我是否缺less一些asynchronousfunction? 我注意到的一件事是,当我注释掉“done()”时,在所有事情都已经发生的几秒钟之后,日志开始向每一个调用validateObject的迭代显示其中的一个:

 A Jasmine spec timed out. Resetting the WebDriver Control Flow. The last active task was: unknown F Failures: 1) ----Bulkd Process----- testing the whole bulk process Message: Expected '1.0' to equal '1.1'. 

所有的console.logs都会立即显示在日志和方式之前。 所以看起来done在expect函数被处理之前调用。 这可能是什么原因? expect()asynchronous?

现在我只是使用“应该”库。 这就像一个魅力。 不过,我想知道我做错了什么。

你错过it 。 请参阅http://jasmine.github.io/2.0/introduction.html关于茉莉花的文档。

您可能还需要更改超时时间: https : //github.com/angular/protractor/blob/master/docs/timeouts.md#timeouts-from-jasmine