0

The very basic test in hapijs/lab fails:

'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);
    });
});

with this message:

  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)

The test is straight from Lab documentation. Any idea what is going wrong?

svakili
  • 1,909
  • 4
  • 19
  • 24

2 Answers2

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?

metoikos
  • 1,315
  • 11
  • 18
0

Updating to the latest version of lab and code fixed this for me

Babalola Rotimi
  • 319
  • 5
  • 10