我试图找出为什么这个测试运行两次:
it ( "should verify file exists with a one name filename ", function ( done ){
var fileNameOneChar = "/Users/myusername/t.mp3";
console.log(" the file path ", fileNameOneChar );
expect( myApi.fileExists( fileNameOneChar ) ).to.be( true );
done();
});
Run Code Online (Sandbox Code Playgroud)
测试连续运行两次(尽管只定义了一次),第一次通过(没关系,该文件实际存在并且 api 工作正常),第二次失败并出现错误:“错误:超时”超过 5000ms”。
为什么测试运行两次?我到处寻找超时错误已经有一段时间了,在摩卡上还没有找到任何东西。
几分钟前,同样的事情发生在我身上,我找到了一个解决方法(不是修复):在同步模式下运行测试。
基本上你需要避免设置it方法的 did 参数
下面是我的测试现在的样子
describe('API /users Endpoint', function () {
it('GET /users should return a JSON list of users', function (done) {
request
.get(config.api.prefix+'users')
.set('bearer',config.api.key)
.end(function(err,res){
if (err) {
return done(err);
}
res.statusCode.should.equal(200);
res.body.should.not.be(null);
res.body.posts.should.not.be(undefined);
res.body.posts.should.not.have.length(0);
});
});
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你!
| 归档时间: |
|
| 查看次数: |
2852 次 |
| 最近记录: |