我用frisby.js写了RestAPI TEST .

如果测试结果为True,则没有probrem . 但如果测试结果为False,则Frisby在Linux上无法正确报告 . (在Windows上正确报告)

以下是示例代码:

const frisby = require('frisby');
const Joi = frisby.Joi;

describe('TEST', () => {
  it ('should return a status of 200', (done) =>{
    frisby
      .get('https://jsonfeed.org/feed.json')
      .expect('status', 400) //deliberately error
      .done(done);
  });
});

如果此spec.js在Windows上运行,则结果如下

> jasmine-node .
F

Failures:
1) TEST should return a status of 200
 Message:
   Expected 'AssertionError: HTTP status 400 !== 200
  at FrisbySpec.status ([mydirpath]\expects.js:25:12)
  (snip)

但是,如果spec.js在Linux(Ubuntu)上运行,结果如下

(node:28704) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: HTTP status 400 !== 200
    at FrisbySpec.status (/home/nsco/jen_work/frisby/node_modules/frisby/src/frisby/expects.js:25:12)
    at FrisbySpec._addExpect.response (/home/nsco/jen_work/frisby/node_modules/frisby/src/frisby/spec.js:368:23)
    at FrisbySpec._runExpects (/home/nsco/jen_work/frisby/node_modules/frisby/src/frisby/spec.js:260:24)
    at _fetch.fetch.then.then.responseBody (/home/nsco/jen_work/frisby/node_modules/frisby/src/frisby/spec.js:139:14)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
(node:28704) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:28704) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
F

Failures:

  1) TEST should return a status of 200
   Message:
     timeout: timed out after 5000 msec waiting for spec to complete
   Stacktrace:
     undefined

“失败:”部分显示为“超时” . (在Windows上,显示为“预期的'AssertionError:HTTP状态400!== 200” . 这是正确的 . )

环境:

  • frisby@2.0.11

  • jasmine-node@1.14.5

  • node / 9.4.0

  • Ubuntu16.04