Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

15.0.0 Release Notes #770

Closed
geek opened this issue Oct 24, 2017 · 0 comments
Assignees
Milestone

Comments

@geek
Copy link
Member

@geek geek commented Oct 24, 2017

Summary

lab 15 drops support for ending tests by executing the done callback and running tests in parallel. All tests now are executed using async/await and should be much simpler to construct as a result. As a result, support for Node.js versions prior to 8 are no longer supported.

Breaking Changes

  • Node.js 8 or later is only supported. I'll continue to support lab 14, so don't worry if you aren't ready to migrate to Node.js 8 yet.
  • Test signatures no longer are passed a done function, instead they receive flags which is an object with functions for note and can be assigned an onCleanup property with a function to execute for performing cleanup operations.
  • Domains are no longer relied on, as a result, the complexity around supporting parallel became too great... parallel test execution is no longer supported.
  • The console reporter now reports debug information by default and the debug flag is removed.
  • The assertion library code is no longer included by default. You will need to include code and assign it to the --assert argument if you intend to use it.

Upgrade Guidance

For most tests that perform asynchronous operations you will need to either switch to using async/await or return a promise that wraps your callback. Below are a couple of examples of tests from lab 14 and what they should look like with lab 15.

Sync

lab 14

it('returns true when 1 + 1 equals 2', (done) => {

    expect(1 + 1).to.equal(2);
    done();
});

lab 15

it('returns true when 1 + 1 equals 2', () => {

    expect(1 + 1).to.equal(2);
});

Async

lab 14

it('can read a file', (done) => {

    Fs.readFile('./file', (err, file) => {

       expect(file).to.exist();
       done();
    });
});

lab 15

it('can read a file', async () => {

    const readFile = Util.promisify(Fs.readFile);
    const file = await readFile('./file');
    expect(file).to.exist();
});
@geek geek added this to the 15.0.0 milestone Oct 24, 2017
@geek geek self-assigned this Oct 24, 2017
@geek geek added the release notes label Oct 24, 2017
@geek geek closed this Oct 25, 2017
duncannixon added a commit to DEFRA/waste-permits that referenced this issue Oct 26, 2017
hapijs/lab#770

Lab version 15 drops support for ending tests by executing the done callback and running tests in parallel. All tests now are executed using async/await and as a result, support for Node.js versions prior to 8 are no longer supported.

This was a breaking change that required all of our unit tests to be amended to use async/await rather than callbacks.
skeggse added a commit to skeggse/isemail that referenced this issue Jan 18, 2018
Lab only supports node >=8 now: hapijs/lab#770.
@hueniverse hueniverse changed the title 15.0.0 Release Notes - WIP 15.0.0 Release Notes Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.