0

hapijs/lab 中非常基本的测试失败:

'use strict';
const Code = require('code');
const expect = Code.expect;
const Lab = require('lab');
const lab = exports.lab = Lab.script();

lab.experiment('math', () => {
    lab.test('returns true when 1 + 1 equals 2', () => {
        expect(1 + 1).to.equal(2);
    });
});

与此消息:

  1) math returns true when 1 + 1 equals 2:
      Function for "math returns true when 1 + 1 equals 2" should either take a callback argument or return a promise
      at Immediate.setImmediate [as _onImmediate] (/home/ubuntu/projects/service/node_modules/lab/lib/runner.js:755:20)
      at runCallback (timers.js:810:20)
      at tryOnImmediate (timers.js:768:5)
      at processImmediate [as _immediateCallback] (timers.js:745:5)
1 of 1 tests failed
Test duration: 29 ms
Assertions count: 0 (verbosity: 0.00)

该测试直接来自实验室文档。知道出了什么问题吗?

4

2 回答 2

0

I saved your code to test.js then

/ ➜ △ ◒ ➜ node --version
v10.3.0

/ ➜ △ ◒ ➜ node test.js

  .

1 tests complete Test duration: 7 ms No global variable leaks detected

It's odd, maybe it is related with your node version?

于 2018-09-26T07:31:50.343 回答
0

更新到最新版本labcode为我解决了这个问题

于 2019-03-20T22:47:52.660 回答