我可以打电话给'Promise.prototype.catch()'在Jest的测试用例中?

时间:2017-09-20 22:48:33

标签: node.js es6-promise jestjs

Jest正在报道:

TypeError: Cannot read property 'getFileName' of undefined

      at Function.write (../../../AppData/Roaming/npm/node_modules/jest/node_modules/jest-util/build/buffered_console.js:33:24)

当我这样做时:

test('wrap template', () => {
  expect.assertions(1)

  return generate(_cwd)
  .then(done => {
    let builtPageName = path.basename(done.shift())
    expect(builtPageName).toBe('indx.html')
   })
  .catch(console.error)
})

但是当我删除.catch(console.error)时,它就像往常一样打印出来:

expect(received).toBe(expected)

    Expected value to be (using ===):
      "indx.html"
    Received:
      "index.html"

      at generate.then.done (lib/__tests__/template.test.js:25:27)

现在,我希望从测试工具中看到这份报告。

那么,当使用/不使用.catch(...)运行测试用例时会发生什么?

我在node 6.11.2处运行npm 5.4.0jest 21.1.0Windows 7

full source code for this case也可用。

0 个答案:

没有答案
相关问题