测试出现2条期望语句时的超时

时间:2018-11-06 07:39:02

标签: javascript testing promise coffeescript

我的CoffeeScript测试中包含以下内容:

# List 1st bucket to find 1 object
.then -> 
  s3.listObjectsV2(
    Bucket: bucketName
  ).promise()

.then (data) ->
  expect(data.Contents.length).to.deep.equal(1)

# List 2nd bucket to find an empty list of objects
.then -> 
  s3.listObjectsV2(
    Bucket: bucketName2
  ).promise()

.then (data) ->
  expect(data.Contents.length).to.deep.equal(0)

此错误Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

如果我删除以下其中一项:

  .then (data) ->
    expect(data.Contents.length).to.deep.equal(1)

或:

  .then (data) ->
    expect(data.Contents.length).to.deep.equal(0)

测试通过。我感觉这与一个承诺不返回bir有关,什么原因导致在同时出现两个expect语句时测试失败?

1 个答案:

答案 0 :(得分:0)

我最终添加:

this.timeout(5000);

现在测试通过了