node.js – 期望在Jasmine中不能完全正常工作

我正在使用量角器进行jasine测试,我不确定预期是如何工作的.我希望茉莉花给我一个失败,因为我显然有一个失败的期望.但事实并非如此.

我使用grunt-protractor-runner 1.2.1,它使用Jasmine2.

我有这个测试用例:

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);
    });
});

知道我在这里缺少什么吗?我错过了一些异步功能吗?
我注意到的一件事是,当我注释掉’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.log都会立即显示在日志中.
因此看起来在处理expect函数之前调用done.可能是什么原因?是expect()异步?

现在我只是使用“应该”库.这就像一个魅力.我仍然想知道我做错了什么.

解决方法

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...