Installation:

npm: npm install @hapi/lab

yarn: yarn add @hapi/lab

Introduction

lab is a simple test utility for Node.js. Unlike other test utilities, lab uses only async/await features and includes everything you should expect from a modern Node.js test utility. Our goal with lab is to keep the execution engine as simple as possible, and not try to build an extensible framework.

lab works best with the code assertion library but can be used with any assertion library that throws an error when a condition isn't met.

Usage

By default, lab loads all the '*.js' files inside the local 'test' directory and executes the tests found. To use different directories or files, pass the file or directories as arguments:

$ lab unit.js

Test files must require the lab module, and export a test script:

const Code = require('@hapi/code');
const Lab = require('@hapi/lab');

const { expect } = Code;
const { it } = exports.lab = Lab.script();

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

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

Or

const Code = require('@hapi/code');
const Lab = require('@hapi/lab');

const { expect } = Code;
const lab = exports.lab = Lab.script();

lab.test('returns true when 1 + 1 equals 2', () => {

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

If a test is performing an asynchronous operation then it should use the async / await keywords or return a Promise. For example:

lab.test('config file has correct value', async () => {

    const file = await fs.readFile('config');
    expect(file.toString()).to.contain('something');
});

Tests can be organized into experiments:

lab.experiment('math', () => {

    lab.test('returns true when 1 + 1 equals 2', () => {

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

If you need to perform some setup operations before or after executing the tests inside an experiment, the before() and after() methods can be used. To execute code before or after each test in an experiment, use beforeEach() and afterEach().

lab.experiment('math', () => {

    lab.before(() => {

        return new Promise((resolve) => {

            // Wait 1 second
            setTimeout(() => {

                resolve();
            }, 1000);
        });
    });

    lab.beforeEach(() => {

        // Run before every single test
    });

    lab.test('returns true when 1 + 1 equals 2', () => {

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

test(), before(), beforeEach(), after() and afterEach() also support returning promises just as tests do:

lab.experiment('math', () => {

    lab.before(() => {

        return aFunctionReturningAPromise();
    });

    lab.test('returns true when 1 + 1 equals 2', () => {

        return aFunctionReturningAPromise()
            .then((aValue) => {

                expect(aValue).to.equal(expectedValue);
            });
    });
});

Both test() and experiment() accept an optional options argument which must be an object with the following optional keys:

  • timeout - set a test or experiment specific timeout in milliseconds. Defaults to the global timeout (2000ms or the value of -m).
  • skip - skip execution. When used on an experiment, all children will be skipped - even if they are marked with only.
  • only - marks all other tests or experiments with skip.

You can also append .only(…) or .skip(…) to test and experiment instead of using options:

lab.experiment('with only', () => {

    lab.test.only('only this test will run', () => {

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

    lab.test('another test that will not be executed', () => {});
});

Behavior Driven Development

To make lab look like BDD:

const Code = require('@hapi/code');
const Lab = require('@hapi/lab');

const { expect } = Code;
const { after, before, describe, it } = exports.lab = Lab.script();

describe('math', () => {

    before(() => {});

    after(() => {});

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

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

Test Driven Development

To make lab look like TDD:

const Code = require('@hapi/code');
const Lab = require('@hapi/lab');

const { expect } = Code;
const { suite, test } = exports.lab = Lab.script();

suite('math', () => {

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

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

Best practices

  • Add lab as a dev dependency to your project's package.json along with a test script:
{
  "devDependencies": {
    "lab": "21.x.x"
  },
  "scripts": {
    "test": "lab -t 100",
    "test-cov-html": "lab -r html -o coverage.html"
  }
}

Note that npm test will execute lab with the -t 100 option which will require 100% code coverage. Run npm run test-cov-html and check the coverage.html file to figure out where coverage is lacking. When coverage is below the threshold, the CLI will exit with code 1 and will result in an npm Error message.

  • Run your tests with
$ npm test

Timeouts

before(), after(), beforeEach(), afterEach() accept an optional options argument which must be an object with the following optional keys:

  • timeout - set a specific timeout in milliseconds. Disabled by default or the value of -M.
lab.experiment('math', { timeout: 1000 }, () => {

    lab.before({ timeout: 500 }, () =>  {

        doSomething();
    });

    lab.test('returns true when 1 + 1 equals 2', () =>  {

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

Transforms

To use source transforms, you must specify a file with the -T command line option that tells Lab how to do the transformation. You can specify many extensions with different transform functions such as .ts or .jsx.

TypeScript

A TypeScript definition file is included with lab to make it easier to use inside of an existing TypeScript project. Below is a TypeScript test example that uses the lab-transform-typescript module to manage the transform:

import * as Lab from 'lab';
import { expect } from '@hapi/code';

const lab = Lab.script();
const { describe, it, before } = lab;
export { lab };


describe('experiment', () => {

    before(() => {});

    it('verifies 1 equals 1', () => {

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

Then the test can be executed using the following command line:

$ lab --sourcemaps --transform node_modules/lab-transform-typescript

Command Line

lab supports the following command line options:

  • -a, --assert - name of assert library to use. To disable assertion library set to false.
  • --bail - terminate the process with a non-zero exit code on the first test failure. Defaults to false.
  • -c, --coverage - enables code coverage analysis.
  • --coverage-path - sets code coverage path.
  • --coverage-exclude - sets code coverage excludes.
  • --coverage-all - report coverage for all matched files, not just those tested.
  • --coverage-flat - do not perform a recursive find of files for coverage report. Requires --coverage-all
  • --coverage-pattern - only report coverage for files with the given pattern in the name. Defaults to pattern. Requires --coverage-all
  • -C, --colors - enables or disables color output. Defaults to console capabilities.
  • -d, --dry - dry run. Skips all tests. Use with -v to generate a test catalog. Defaults to false.
  • -e, --environment - value to set the NODE_ENV environment variable to, defaults to 'test'.
  • -f, --flat - do not perform a recursive load of test files within the test directory.
  • -g, --grep - only run tests matching the given pattern which is internally compiled to a RegExp.
  • -h, --help - show command line usage.
  • -i, --id - only run the test for the given identifier (or identifiers range, e.g. lab -i 1-3,5). Use lab -dv to print all tests and their identifier without running the tests. This is an alias of ids array property in .labrc file.
  • -I, --ignore - ignore a list of globals for the leak detection (comma separated), this is an alias of globals property in .labrc file. To ignore symbols, pass the symbol's string representation (e.g. Symbol(special)).
  • --inspect - start lab in debug mode using the V8 Inspector.
  • --inspect-brk - see --inspect.
  • -l, --leaks - disables global variable leak detection.
  • -L, --lint - run linting rules using linter. Disabled by default.
  • --lint-errors-threshold - maximum absolute amount of linting errors. Defaults to 0.
  • --lint-warnings-threshold - maximum absolute amount of linting warnings. Defaults to 0.
  • --lint-fix - apply any fixes from the linter, requires -L or --lint to be enabled. Disabled by default.
  • --lint-options - specify options to pass to linting program. It must be a string that is JSON.parse(able).
  • -m, --timeout - individual tests timeout in milliseconds (zero disables timeout). Defaults to 2 seconds.
  • -M, --context-timeout - default timeouts for before, after, beforeEach and afterEach in milliseconds. Disabled by default.
  • -o, --output - file to write the report to, otherwise sent to stdout.
  • -p, --default-plan-threshold - sets the minimum number of assertions a test must run. Overridable with plan.
  • -P, --pattern - only load files with the given pattern in the name.
  • -r, --reporter - the reporter used to generate the test results. Defaults to console. Options are:
    • console - text report.
    • html - HTML test and code coverage report (sets -c).
    • json - output results in JSON format.
    • junit - output results in JUnit XML format.
    • tap - TAP protocol report.
    • lcov - output to lcov format.
    • clover - output results in Clover XML format.
    • Multiple Reporters - See Below
    • Custom Reporters - See Below
  • --shuffle - randomize the order that test scripts are executed. Will not work with --id.
  • --seed - use this seed to randomize the order with --shuffle. This is useful to debug order dependent test failures.
  • -s, --silence - silence test output, defaults to false.
  • -S, --sourcemaps - enables sourcemap support for stack traces and code coverage, disabled by default.
  • -t, --threshold - sets the minimum code test coverage percentage to 100%.
  • --types-test - sets a single TypeScript definition test file (implies -Y). Use when the test directory contains other TypeScript files that should not be loaded for definition testing.
  • -T, --transform - javascript file that exports an array of objects ie. [ { ext: ".js", transform: (content, filename) => { ... } } ]. Note that if you use this option with -c (--coverage), then you must generate sourcemaps and pass sourcemaps option to get proper line numbers.
  • -v, --verbose - verbose test output, defaults to false.
  • -V, --version - display lab version information.
  • -Y, --types - validate the module TypeScript types definitions. This is designed exclusively for JavaScript modules that export a TypeScript definition file.

Methods

Lab.script([options])

Generates a test script interface which is used to add experiments and tests, where:

  • options - an optional object with the following optional keys:
    • schedule - if false, an automatic execution of the script is disabled. Automatic execution allows running lab test scripts directly with Node.js without having to use the CLI (e.g. node test/script.js). When using lab programmatically, this behavior is undesired and can be turned off by setting schedule to false. If you need to see the output with schedule disabled you should set output to process.stdout. Defaults to true.
    • cli - allows setting command line options within the script. Note that the last script file loaded wins and usage of this is recommended only for temporarily changing the execution of tests. This option is useful for code working with an automatic test engine that run tests on commits. Setting this option has no effect when not using the CLI runner. For example setting cli to { ids: [1] } will only execute the first test loaded.

script.after([options], action)

Executes the provided action after the current experiment block is finished where:

  • options - optional flags as describe in script.test().
  • action - a sync or async function using the signature function(flags) where:

script.afterEach()

Executes the provided action after each test is executed in the current experiment block where:

  • options - optional flags as describe in script.test().
  • action - a sync or async function using the signature function(flags) where:

script.before()

Executes the provided action before the current experiment block is started where:

  • options - optional flags as describe in script.test().
  • action - a sync or async function using the signature function(flags) where:

script.beforeEach()

Executes the provided action before each test is executed in the current experiment block where:

  • options - optional flags as describe in script.test().
  • action - a sync or async function using the signature function(flags) where:

script.describe(title, [options], content)

Same as script.experiment().

script.experiment(title, [options], content)

Sets up an experiment (a group of tests) where:

  • title - the experiment description.
  • options - optional settings:
    • skip - if true, sets the entire experiment content to be skipped during execution. Defaults to false.
    • only - if true, sets all other experiments to skip. Default to false.
    • timeout - overrides the default test timeout for tests and other timed operations. Defaults to 2000.
  • content - a function with signature function() which can setup other experiments or tests.

script.experiment.only(title, [options], content)

Same as script.experiment() with the only option set to true.

script.experiment.skip(title, [options], content)

Same as script.experiment() with the skip option set to true.

script.it(title, [options], test)

Same as script.test().

script.suite(title, [options], content)

Same as script.experiment().

script.test(title, [options], test)

Sets up a test where:

  • title - the test description.
  • options - optional settings:
    • skip - if true, sets the entire experiment content to be skipped during execution. Defaults to false.
    • only - if true, sets all other experiments to skip. Default to false.
    • timeout - overrides the default test timeout for tests and other timed operations in milliseconds. Defaults to 2000.
    • plan - the expected number of assertions the test must execute. This setting should only be used with an assertion library that supports a count() function, like code.
  • test - a function with signature function(flags) where:
    • the function can throw if the test failed.
    • the function can return a Promise which either resolves (success) or rejects (fails).
    • all other return value is ignored.
    • flags - a set of test utilities described in Flags.
lab.experiment('my plan', () => {

    lab.test('only a single assertion executes', { plan: 1 }, () => {

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

script.test.only(title, [options], test)

Same as calling script.test() with only option set to true.

script.test.skip(title, [options], test)

Same as calling script.test() with skip option set to true.

Flags

The test function is passed a flags object that can be used to create notes or set a function to execute for cleanup operations after the test is complete.

context

An object that is passed to before and after functions in addition to tests themselves. context is used to set properties inside the before function that can be used by a test function later. It is meant to reduce module level variables that are set by the before / beforeEach functions. Tests aren't able to manipulate the context object for other tests.

lab.before(({ context }) => {

    context.foo = 'bar';
})

lab.test('contains context', ({ context }) => {

    expect(context.foo).to.equal('bar');
});

mustCall(func, count)

Sets a requirement that a function must be called a certain number of times where:

  • func - the function to be called.
  • count - the number of required invocations.

Returns a wrapped copy of the function. After the test is complete, each mustCall assertion will be checked and the test will fail if any function was called the incorrect number of times.

Below is an example demonstrating how to use mustCall to verify that fn is called exactly two times.

lab.test('fn must be called twice', async (flags) => {

    const fn = () => {};
    const wrapped = flags.mustCall(fn, 2);
    wrapped();

    await doSomeAsyncOperation();
    wrapped();
});

note(note)

Adds notes to the test log where:

  • note - a string to be included in the console reporter at the end of the output.

For example, if you would like to add a note with the current time, your test case may look like the following:

lab.test('attaches notes', (flags) => {

    expect(1 + 1).to.equal(2);
    flags.note(`The current time is ${Date.now()}`);
});

Multiple notes can be appended for the same test case by simply calling note() repeatedly.

onCleanup

A property that can be assigned a cleanup function registered at runtime to be executed after the test completes. The cleanup function will execute even in the event of a timeout or error. Note that the cleanup function will be executed as-is without any timers. The function assigned to onCleanup can return a Promise that will be evaluated.

lab.test('cleanups after test', (flags) => {

    flags.onCleanup = () => {

        cleanup_logic();
    };

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

onUncaughtException

A property that can be assigned an override for global exception handling. This can be used to test the code that is explicitly meant to result in uncaught exceptions.

lab.test('leaves an uncaught rejection', (flags) => {

    return new Promise((resolve) => {

        flags.onUncaughtException = (err) => {

            expect(err).to.be.an.error('I want this exception to remain uncaught in production');
            resolve(); // finish the test
        };

        // sample production code
        setTimeout(() => {

            throw new Error('I want this exception to remain uncaught in production');
        });
    });
});

onUnhandledRejection

A property that can be assigned an override function for global rejection handling. This can be used to test the code that is explicitly meant to result in unhandled rejections.

lab.test('leaves an unhandled rejection', (flags) => {

    return new Promise((resolve) => {

        flags.onUnhandledRejection = (err) => {

            expect(err).to.be.an.error('I want this rejection to remain unhandled in production');
            resolve(); // finish the test
        };

        // sample production code
        setTimeout(() => {

            Promise.reject(new Error('I want this rejection to remain unhandled in production'));
        });
    });
});

.labrc.js File

lab supports a .labrc.js configuration file for centralizing lab settings. The .labrc.js file can be located in the current working directory, any directory that is the parent of the current working directory, or in the user's home directory. The .labrc.js file needs to be able to be required by Node.js. Therefore, either format it as a JSON file or with a module.exports that exports an object with the keys that are the settings.

Below is an example of a .labrc.js file to enable linting and test coverage checking:

module.exports = {
    coverage: true,
    threshold: 90,
    lint: true
};

Setting precedent

The .labrc.js file will override the lab default settings. Any options passed to the lab runner will override the settings found in .labrc.js. For example, assume you have the following .labrc.js file:

module.exports = {
    coverage: true,
    threshold: 100
};

If you need to reduce the coverage threshold for a single run, you can execute lab as follows:

lab -t 80

Available settings

The .labrc.js file supports configuration keys that are named with the long name of the command line settings. Therefore, if you need to specify an assert library, you would export a key named "assert" with the desired value.

In addition, you can use the paths parameter to override the default test directory (i.e. ./test):

module.exports = {
    paths: ['test/lab'],
};

As stated at the beginning of the document, --ignore parameter is an alias for globals option in the .labrc file. Therefore if you wish to ignore specific files you'll need to append a globals setting, not an ignore one, as stated on #641.

Linting

lab uses a shareable eslint config, and a plugin containing several hapi specific linting rules. If you want to extend the default linter you must:

  1. Add eslint-plugin-hapi and eslint-config-hapi as dependencies in your package.json. You must add both the plugin and the config because eslint treats them as peer dependencies. For more background, see eslint/eslint#3458 and eslint/eslint#2518.

  2. In your project's eslint configuration, add "extends": "eslint-config-hapi". eslint will automatically infer the eslint-config-, so technically you can just write "extends": "hapi".

Your project's eslint configuration will now extend the default lab configuration.

Ignoring files in linting

Since eslint is used to lint, you can create an .eslintignore containing paths to be ignored:

node_modules/*
**/vendor/*.js

Only run linting

In order to run linting and not to execute tests you can combine the dry run flag with the lint flag.

lab -dL

Integration with an assertion library

Using the --assert argument allows you to integrate Lab with your favorite assertion library. Aside from --assert from the CLI you can change the assert option when executing report. Whatever assertion library you specify is imported and assigned to the Lab.assertions property. Here is an example using lab --assert code:

const lab = exports.lab = Lab.script();
const { describe, it } = lab;

// Testing shortcuts
const { expect, fail } = require('@hapi/code');

describe('expectation', () => {

    it('should be able to expect', () => {

        expect(true).to.be.true();
    });

    it('should be able to fail (This test should fail)', () => {

        fail('Should fail');
    });
});
$ lab --assert code

If you use the Code assertion library Lab will let you know if you have any missing assertions. An example of this is:

describe('expectation', () => {

    it('Test should pass but get marked as having a missing expectation', () => {

        // Invalid and missing assertion - false is a method, not a property!
        // This test will pass.
        Lab.expect(true).to.be.false;
    });
});

This is an invalid test but it will pass as the .false assertion was not actually called. Lab will report the number of incomplete assertions, their location in your code and return a failure of the tests.

Similarly, if you use an assertion library, lab will be able to report the verbosity of your tests. This is a measure of the number of assertions divided by the number of tests. The value will be output when using the console reporter and can be helpful in determining if too many or too few assertions exist in each test. What is too many or too few assertions is entirely up to you.

Debuggers

lab can be started with the option --inspect which will run it with the V8 Inspector.

This debugger can be accessed using the URL that is printed in the console, or used in association with a few Chrome extensions (Node.js V8 Inspector, NIM, etc).

As you may know, if your tests are associated with the command npm test, you can already run npm test -- --inspect to run it with the inspector and avoid creating another command. If you want to listen on a specific port for the inspector, pass --inspect={port}.

lab also has automatic support for the WebStorm debugger, just start a normal debugging session on your npm test script.

Multiple Reporters

Multiple reporters can be specified by providing multiple reporter options.

$ lab -r console -r html

If any output -o is provided, they must match the same number of provided reporter options. The reporters would be paired with an output based on the order in which they were supplied. When specifying multiple outputs, use stdout to send a particular reporter to stdout.

$ lab -r console -o stdout -r html -o coverage.html -r lcov -o lcov.info -r json -o data.json

In a .labrc.js file, multiple reporters and their associated output paths would be represented as follows:

module.exports = {
    reporter: ['console', 'html', 'lcov', 'json'],
    output: ['stdout', 'coverage.html', 'lcov.info', 'data.json']
};

Multiple reporters of the same kind are also supported.

$ lab -r console -o stdout -r console -o console.log

Custom Reporters

If the value passed for reporter isn't included with Lab, it is loaded from the filesystem. If the string starts with a period ('./custom-reporter'), it will be loaded relative to the current working directory. If it doesn't start with a period ('custom-reporter'), it will be loaded from the node_modules directory, just like any module installed using npm install.

Reporters must be a class with the following methods: start, test and end. options are passed to the class constructor upon initialization.

See the json reporter for a good starting point.

Coverage

Sometimes you want to disable code coverage for specific lines, and have the coverage report omit them entirely. To do so, use the $lab:coverage:(off|on)$ comments. For example:

// There is no way to cover this in node 0.10
/* $lab:coverage:off$ */
if (typeof value === 'symbol') {
    // do something with value
}
/* $lab:coverage:on$ */

Coverage Bypass Stack

Disabling code coverage becomes tricky when dealing with machine-generated or machine-altered code. For example, babel can be configured to disable coverage for generated code using the auxiliaryCommentBefore and auxiliaryCommentAfter options. The naïve approach to this uses $lab:coverage:on$ and $lab:coverage:off$, but these directives overwrite any user-specified directives, so that a block where coverage should be disabled may have that coverage unintentionally re-enabled. To work around this issue, lab supports pushing the current code coverage bypass state onto an internal stack using the $lab:coverage:push$ directive, and supports restoring the top of the stack using the $lab:coverage:pop$ directive:

// There is no way to cover this in node < 10.0.0
/* $lab:coverage:off$ */
const { types } = Util;
const isSet = (types && types.isSet) || (set) => set instanceof Set;
/* $lab:coverage:on$ */

// When Util is imported using import and babel transpiles to cjs, babel can be
// configured to use the stack:
/* $lab:coverage:off$ */
const {
  types
} =
/*$lab:coverage:push$/
/*$lab:coverage:off$*/
_util
/*$lab:coverage:pop$/
.
/*$lab:coverage:push$/
/*$lab:coverage:off$*/
default
/*$lab:coverage:pop$*/
;
const isSet = types && types.isSet || (set) => set instanceof Set;
/* $lab:coverage:on$ */

Semantics:

  • $lab:coverage:push$ copies the current skip state to the top of the stack, and leaves it as the current state as well
  • $lab:coverage:pop$ replaces the current skip state with the top of the stack, and removes the top of the stack
    • if the stack is empty, lab will tell you by throwing the error "unable to pop coverage bypass stack"

Excluding paths from coverage reporting

The --coverage-exclude argument can be repeated multiple times in order to add multiple paths to exclude. By default the node_modules and test directories are excluded. If you want to exclude those as well as a directory named public you can run lab as follows:

lab -c --coverage-exclude test --coverage-exclude node_modules --coverage-exclude public

Acknowledgements

lab initial code borrowed heavily from mocha, including the actual code used to render the coverage report into HTML. lab coverage code was originally adapted from blanket which in turn uses falafel.

Changelog

21.0.0
breaking changes
#950
Update types
#949
Drop node 8
#948
Tags to skip types test line execution
#945
coverage-all option triggers TypeError: Cannot set property 'source' of undefined
#943
Fails to load npm modules in ts tests
#942
Support types test execution on windows
#941
External modules coverage fails on windows due to path
#940
Run TS tests, not just validate them
#924
New diff is broken
#856
coverage analysis modifies a function return
#938
Stupid typescript
#937
Support coverage of external modules with own coverage reports
#936
Ignore symbol leaks
#933
Update to eslint 6
#932
Single line coverage ignore
#926
Implement coverage bypass stack
#923
Support multiple "only" flags
#922
Support for multiple "only"
#904
Add affordance for coverage flag stack
#921
Handle ts "Cannot find name" error when expected
#920
19.0.0 Release Notes
#919
Change console reporter labels
#918
Typescript test support
#917
Remove debug-brk
#916
Global leak detector skips Symbol() properties
#915
Use util.inspect() for console reporter
#914
"console" reporter crashes if object contains a BigInt
#572
No mismatch highlighted on -0 !== 0 deep equality mismatch
#913
Update lint rules modules
#912
Add globalThis to symbols
#911
Update code
#910
Change module namespace
#905
Update deps
#898
Switch back to Hoek.clone from lodash.deepClone.
#895
Fix coverage with sourcemaps inlined via Transform API.
18.0.0
breaking changes
#893
Properly propagate term sig to child lab process
#892
Add note about how to get a tests ID
#891
Update eslint version
#890
Remove deprecated espree option
#889
Remove docs about custom linter option
#888
Compare coverage pattern to canonical path
#885
Centralize espree options
#884
Remove old parallel flag from test
#883
Use correct gray color code
#882
Add missing coverage and remove unnecessary checks
#878
Fix false-positive coverage of if statements (REDUCES REPORTED COVERAGE!)
#855
Update linter configuration?
#852
Console reporter: "gray" is actually light green
#842
Coverage fails for multiple conditionals on same line (logical operators)
#788
Documentation on using --id
#762
Request to consolidate parsers
#758
CLI failure test doesn't appear to test what it claims
#881
Add coverage-pattern option
#880
Remove engines
#853
Coverage being analized on the test file
#879
Check file pattern on coverage traversal
#877
Add --coverage-all option
#710
setting coverage-path doesn't include all code in path
#876
Update dependencies
#875
Revert console cov report truncation
#871
Improve console coverage report readability
#874
Update hoek v6
#873
Fails to handle non-Error errors
#870
Update type definitions to match documented API
#869
[ENHANCEMENT] Nullified test context on finish to prevent memory leaks
#868
Possible context memory leak?
#867
No longer skip scripts when multiple only
17.0.0
breaking changes
#866
Add node 11 to travis
#865
handle queueMicrotask global added in Node 11
#864
Add testsuites output to junit
#863
Upgrade source-map and support limited sourcemap descriptors
#860
Fixed skipped console output color
#846
Only is no longer limited to 1 test
#845
junit report generated has both classname and the name as "classname + ' ' + name".
#750
html reporter errors when encountering sourcemap chunks with typescript
#858
Update ecmaversion in eslint
#851
Fix stack trace trimming
#850
Document `paths` parameter in .labrc.js
16.0.0
breaking changes
#849
Update to eslint v5
#844
Disable dep timeout, which is doc default
#843
Allow custom handling for global errors/rejections
#840
update eslint-config-hapi dependency
#782
Disable "uncaughtException" handler for tests
#729
-M, --context-timeout is ignored; test passed even it is not triggered
#838
Support test context from befores
#837
Add BigInt globals
#836
Update coverage ECMA version to 9 (2018).
#833
Add WHATWG Encoding API globals
#831
Revert "Wait for stdout to stop writing to exit"
#829
Wait for stdout to stop writing to exit
#824
Calculate relative filename using node's path
#823
Transforming files does not work with yarn workspaces
#830
Fix coverage on transformed files. Fixes #826.
#821
Update eslint
#820
Ignore default-plan-threshold for anything else than tests
#819
Implement minimum assertions threshold. Closes #690.
#690
Allow to specify minimum number of executed assertions
#816
Bump diff to 3.5
#815
Update eslint dep
#813
Fail test if a falsy value is thrown by the test
#812
awaiting a rejected promise can still pass test
#811
Can exclude files from coverage
#810
Write CLI errors to stderr
#809
Update eslint version
#808
add URL and URLSearchParams to global variables
#399
Missing exports.lab causes error when generating html coverage report
#807
Report correct exit code with multiple reporters
#806
Add multiple reporter tests
#805
Update eslint version
#804
Using multiple reporters results into wrong exit code if test fails
#803
Update eslint
#802
Support object rest/spread under eslint
#801
update to use expect from code
#797
Update TypeScript typings
#794
Fix usage example of flags.onCleanup
#793
Added index.d.ts to npmignore
#786
Add mustCall feature
#784
Updated readme to include alias of ignore
#641
ignore setting not supported in .labrc.js
#783
Fix for node 9
#779
Remove outdated assert statements
#778
assertion library "code" is not set by default / documentation is wrong
#748
New globals are coming
#776
Fix test script error duplicates
#774
Update eslint
#772
Remove code as default assertion library. Resolves #771
#769
Display parser errors when requiring scripts
#768
Update README.md
#770
15.0.0 Release Notes
#766
Remove domains and callbacks
#765
Use of onCleanup() when test returns a promise
#752
Remove domains in favor of try/catch on async/await
#817
Bump diff to 3.5 (v14.x.x)
#792
Fix for node 9
#763
Update deps: eslint, source-map
#760
Helpful message when path not found
#759
More helpful message when test path not found
#755
Fix RangeError for --id when skipping a large number of tests
#749
update eslint parser version to 8
#746
#647 add example of multiple reporters in .labrc.js
#745
Update deps: eslint/supports-color
#744
Better color detection
#743
Document verbosity value
#742
Fix readme linting issues
#740
add object spread option
#739
Coverage is broken when using object spread operator
#737
Please add an explanation of verbosity; what does 'verbosity: 3.00' mean?
#735
Document definition file
#734
Add TypeScript definition file
#731
Typescript support
#733
Update dependencies: eslint, espree
#732
Be explicit about errors thrown in before/afters
#728
Help: Multiple callbacks error with mongo AND lab.before
#727
Fix failing test
#726
Fix npm 5.2 error
#722
Expose Code features directly on script
#721
Failed befores properly fail related tests
#370
Fail conditions documentation is unclear
#720
Support eslint 4 ignore path
#719
14.0.0 Release Notes
#718
Error on tests with both promise and callback
#717
Update eslint/code versions
#715
Upgrade to ESLint v4
#713
Bundle code as default assertion library
#712
Include code assertion library
#580
Confusing warning when mixing Promise and callback style
#707
Update espree version
#706
upgrade eslint to 3.19.x
#705
Error when doing code coverage: "ecmaVersion must be 3, 5, 6, or 7."
#704
Add WebAssembly to allowed globals
#697
Node 8 will add `WebAssembly` global
#701
Ignore while a promise returns inside a test with a value. Only watch for rejection
#700
Promises that return values now error on finished
#699
Fix a domain leak and onCleanup failures
#698
Improve bail strategy not to execute next befores/afters
#696
Extending linting
#693
plan and Lab.assertions not working
#689
Fix test
#688
Add failing test for conditional value
#686
Fix coverage of zero-comment scripts
#685
TypeError: Reduce of empty array with no initial value
#684
13.0.0 Release Notes
#683
Minor cleanup
#681
Reduce leaked memory via domains and timers
#677
Update eslint version
#648
Original files in HTML reporter
#614
Test coverage shows untransformed output
#674
Typos and inspect supports port
#673
Add support for Node.js and WebStorm debuggers
#651
Implement --inspect so debugging inside a test is possible?
#672
12.0.0 Release Notes
#671
Add --bail support
#670
upgrade espree parser to use ECMAScript latest 8
#668
.labrc.js with --harmony options execute failed
#640
cli `--help` command showing incorrect commands
#214
Stop Tests On First Failure
#666
Update eslint
#665
Fix test and deprecation warning
#664
Update eslint version
#662
fix: don't show seed when shuffle was not enabled
#659
Node 7, update deps
#658
Added a flag (-R, --rejections) to make the test fail if an unhandled Promise rejection happened during its execution
#657
feat: allow to set the seed for --shuffle with --seed.
#656
when tests fail with `--shuffle`, how to run tests in the failing order?
#654
Update eslint to 3.9.x
#653
fixes logic for lab.before timeout #652
#652
disable lab before timeout
#649
Make the test fail on a Promise unhandled rejection
#646
Update deps: eslint, diff
#645
Update eslint
#644
fixing invalid markup on filter checkboxes
#643
Docs: Fix URL in CONTRIBUTING.md
#639
Docs: Added documentation for the assert argument
#634
The `assert` command line flag should be properly documented
#630
Disable debug mode by default
#629
Failed tests reported twice
#624
11.0.0 Release Notes
#622
Test entire node range before bypassing
#621
Update eslint dep
#620
Ensure we're not bypassing loc that should be covered
#619
update to eslint-config-hapi@10.x.x
#459
`/* `$lab:coverage:(off|on)$` */` disables coverage for a whole module
#615
Upgrade eslint to v3
#613
labrc.js can override all cli options
#611
closes #610
#610
Upgrade to eslint@2.13.x
#609
some options can't be configured with .labrc.js
#608
Fix NODE_ENV not being set (fixes #606)
#606
NODE_ENV is no longer defaulting to 'test'
#603
Display a warning for failed patterns
#511
Show better error message when -P fails to find matching patterns
#601
Support .labrc.js for configuration
#599
Cleanup leak harmony checks
#598
Support .labrc files for configuration defaults
#597
Add space after failed test x
#596
Adjust gray to comply with solarized dark theme
#595
Update eslint to v2.10.x
#594
Cleanup lint-fix setting
#593
Support ability to add notes to a test
#591
Add --lint-fix option.
#402
Add ability to attach notes to test results
#589
Update to code v3
#588
Make coverage excludes more explicit
#587
Support the same test name in diff experiments
#461
File Name Coverage Issue
#375
Experiment description not showing in output
#586
Default output to stdout
#585
Document how to only run linting
#584
Don't execute before/after on experiments that lack tests
#583
Better documentation for schedule
#559
Run linting only
#440
before and after blocks
#390
Enable output for single-file usage
#337
Skipped tests should have their beforeEach() skipped too?
#288
self-run scripts don't generate output or respect CLI arguments
#579
Promise test check should allow more than one argument
#578
Post test cleanup. Closes #577
#577
Post test cleanup
#576
Support bossy 3
#575
Update dependencies
#574
id-557: Error thrown when I use --coverage-exclude
#573
use stable stringify for better objects diff
#557
Error thrown when I use --coverage-exclude
#570
Works correctly with node v6
#569
Add Reflect to whitelist
#568
leaks detected:Reflect using node v6.0.0
#556
Code coverage: Always surround expressions in ternary operator with parenthesis
#555
Code coverage for conditional operator with comma operator isn't handled correctly
#554
Update eslint to v2.5
#548
Update README.md
#545
Update deps and fix flushing to stdout
#544
Feature/silent skips
#541
Allow stdout to flush
#538
Add `plan` option for tests
#257
Set expected number of assertions
#537
Feature: promises
#536
Support promises in tests and setup / teardown
#534
Fix "multiple only" error with multiple outputs
#533
Update readme for global only
#530
10.0.0 Release Notes
#527
Global "only" (#524)
#524
Add a global `only` flag to improve TDD experience
#525
Support shuffling execution of scripts
#523
9.0.0 Release Notes
#522
Remove jslint and support custom linters
#507
Add JavaScript Standard Style (`standard`) as a linter option
#282
Make linter pluggable? (PR offer)
#521
Fix coverage of trailing function declaration
#520
Fix coverage report for single-line functions and single-expression arrow functions
#274
Single line functions are not property tested for coverage
#519
update to eslint@2.x.x
#516
upgrade to espree@3.x.x
#515
enable parsing the spread operator
#514
use of the spread operator breaks coverage
#510
Fix coverage when require cache is reset
#508
--coverage-exclude should support multiple paths
#505
Coverage calculated wrong.
#504
Lab .eslintrc rules overrides local eslint rules.
#503
Fix eslint configuration file format support.
#500
fix diff text visibility for console reporter
#493
Diff colors render diff text unreadable
#499
8.0.0 release notes
#498
Update dependencies
#496
update to eslint-config-hapi@8.x.x
#495
Add objectLiteralShorthandMethods to supported ES6 features
#492
Update dependencies items and eslint
#491
Coverage reporting does not support parsing ES6 objectLiteralComputedProperties
#487
Es6-ify the README examples
#479
Update hapijs/items to 2.0.0 from 1.1.1
#484
Update linter to include for loop rules
#480
Update hapi linter dependencies
#478
Update to use ES6 style and lint rules
#477
Es6
#476
ES6 linting rules
#475
consider testing arg passed to done is an error object
#474
7.0.0 release notes
#473
Remove node 0.10 support
#471
Do not add tracking code before "var" in "for(var x of xs)"
#470
for(var x of xs) is not handled correctly when coverage is turned on
#460
Add objectLiteralShorthandMethods to supported ES6 features
#457
Error data
#455
6.0.0 release notes
#454
Update to eslint-config-hapi@3.x.x
#453
Lint warning for unused variables except internals
#452
-V/--version flag to show version
#449
Add --version to CLI
#451
Rename template for npm publish
#448
Add linting information and test failures to html
#447
Upgrade deps and avoid relying on unix commands
#439
Document html coverage report source markup
#445
JSON reporter now supports lint output
#443
add lint results to json reporter
#442
Update insecure dependencies (eslint, handlebars)
#441
Document coverage ignore syntax, fixes #438
#437
Drop camelcase lint rule
#436
Update to eslint-config-hapi@2.x.x
#433
Add Infinity to stringify
#432
Updated eslint version
#431
Add docs for extending lab's linter
#429
Use a shareable config for ESLint
#372
.eslintrc files should build on default settings
#428
Show invisible tokens on stringify
#424
Fix stack traces when using transforms
#421
Fix circular JSON for console reporter
#420
Add command line options to override coverage path and excludes
#416
Allow custom reporters from CLI
#415
Custom reporters not allowed from cli
#414
Fix test for equal call with extra param
#413
Fix extra params passed to equal that are invalid
#412
Update eslint to 1.0.x
#406
Fix exit code when multiple reporters encounter a failure
#404
enable more es6 features for Espree
#397
Attach sub-reporters to the multiple reporter
#393
Exit code always 0 with multiple reporters
#395
Support filename pattern matching in CLI
#384
File name matching glob pattern
#394
Revert lint rule on spaced comments
#392
Attach results to the reporter
#389
Multiple reporters and multiple outputs
#387
Update to eslint 0.24.x and add array bracket spacing linting rule
#386
enable code coverage support with ES6
#381
Added space after comment rule
#385
Support more relaxed no-shadow rule
#380
Update source-map-support to 0.3.x
#379
Shadow lint error going too far
#377
Remove lint rule for line around comments
#376
Lint too aggressive with empty lines before comments
#371
Use no-shadow lint rule
#369
no-catch-shadow
#368
Enforce capitalization of imported module variable names
#366
Linting update
#365
Update license attribute
#364
Cleanup repo style
#362
Default both linting thresholds to 0.
#361
Lint option -L should fail test if any linting problems are found
#360
Use global handle for __$$labCov for use strict.
#359
Change afterEaches to run in more natural order
#358
unable to test when employing template strings
#357
afterEach's run in unnatural order
#356
Fix coverage on loop labels. Fixes #355.
#355
Error when running lab with coverage on babel compiled code
#354
Fix coverage modifying "use strict" statements.
#352
Fix #351. Add message about threshold and npm error message.
#351
npm ERR! Exit status 1 when threshold is not met
#350
Lint thresholds
#349
Add 4 space indent rule
#348
Add some more rules to ESLint
#347
Added two eslint rules to lab to enforce the hapi code style.
#345
Switch to espree
#344
Update dependencies
#332
using `espree` or `acorn` instead of esprima
#341
Fix HTML reporter when using live-transformed code
#339
Add ESLint rule for blank line at beginning of function scope
#327
[DEP] eslint 0.14 to 0.17
#326
Update eslint to 0.17.0
#324
Allow test files to have different extensions with transform
#323
Fix EventEmitter bug
#322
Fix domain not exited
#317
Support custom reporters - closes #216 & closes #309
#321
Allow --lint-options to be passed to configure linters
#320
Fixes #319: Instructs --output to create given directory recursively.
#319
--output should create given directory tree
#318
add debug option to show domain error stack
#316
Properly support sourcemaps when using the transform option
#311
Add live transform of source code before coverage analysis
#308
Remove Makefile and advice about it. Closes #284.
#307
Linting update
#297
Add Intl global
#295
Ignore Intl global
#280
Ignoring files in linting
#290
make linter pluggable
#286
Avoid double timeout on before/after
#278
Fix before/after exceptions to be reported
#277
Errors thrown in after & afterEach can cause immediate exit with code 0
#276
(true ? true : false) ? 'x' : false === true when coverage enabled (should be 'x')
#271
Add Map, Set, and WeakSet to the Harmony globals and improve testing
#262
Fix console reporting
#261
Remove extra hoek typo in package.json
#260
Add verbosity index
#259
5.0.0 Release Notes
#258
Remove extra line breaks in lint report
#256
Assertions library option
#254
Fix documentation to exclude chai
#253
Remove Chai
#252
Lint report formatting
#250
Remove chai
#249
Fix #217: throw on invalid function declaration
#247
Run linting in child process
#246
Remove extra line breaks in report
#245
Spawn linting in child process
#244
Remove extra line breaks
#243
Remove brace-style rule
#242
Remove brace-style lint rule
#241
Lint arg is now a boolean
#240
Removing consistent-return
#239
Drop consistent-return lint rule
#238
Remove no-lonely-if
#237
Switch -L to be boolean and only use eslint
#236
Remove no-lonely-if
#234
Ignore tests for lab
#233
Add eslintignore for labs tests
#232
Fixing lint rules and only showing files when issues
#231
Only show linted files if there are issues
#213
WIP - Add linting support
#226
Support windows console output
#225
Console reporter doesn't display well on windows
#219
Fix mistakes on previous pull requests
#215
Add optional timeouts on before(Each), after(Each)
#207
Fix #178: Add sourcemaps support
#178
Code coverage with sourcemaps support
#212
Fix #209: omit undefined options
#209
code error results in all tests passing
#208
Support multiple tests from the command line.
#205
Output and leaks are honored
#204
CLI: -o not honored
#203
Support junit as reporter on cli
#200
junit reporter unavailable
#199
Add --ignore option and document alias arguments
#198
Add test for unknown arguments
#197
Restrict CLI reporter checks and add usage on errors
#196
Globals
#193
Upping to bossy 1.0.0
#192
Switching from optimist to bossy
#191
Switch from optimist to bossy
#187
Added clover reporter
#182
Adding lcov format reporter
#180
Stray asterisk in README
#179
Add tests for coverage that throws
#109
Option to output coverage in lcov format
#176
Adding test run data to html report
#175
Cleanup tests for timeout overrides
#174
Add lines covered and not covered to the CC report
#118
Way to get coverage report in HTML at the same time as console
#171
4.1.0 Release Notes
#168
updated README to cover JUnit reporter
#167
Document JUnit reporter
#166
Added junit reporter
#165
Junit output
#164
Feature - Prevent clobbered timer globals from interfering with runner
#163
Updating TAP reporter to specification version 13
#162
cli override. Closes #161
#161
Allow setting CLI options programatically
#159
Detect missing exports.lab in the cli runner
#157
Handle tests without a "exports.lab" gracefully
#119
Duration of tests shown via TAP
#155
Clarify how `only` behaves
#154
Skipped tests still reported on console reporter as being run
#152
Set env variable immediately in cli
#151
Environment not set before require when using CLI
#150
Default to test environment
#149
Changed session errors to script errors.
#148
Environment set too late
#147
Replace async with items
#146
Reword session errors to test script errors
#145
Replace use of async with items
#144
Fixing issue with missing labCov reference
#143
lab throws with ReferenceError: __$$labCov is not defined when run with coverage enabled and no code to cover
#141
Add test for while coverage
#140
Default to null for colors on cli for using tty capabilities
#139
CLI colors aren't defaulted to tty capabilities
#137
Moving to authors file and adding my name
#136
Notebook updates
#135
Fix for paths with hyphens and increase timeout
#133
Cli tests
#132
Update readme to reflect all the latest cli options
#130
Add lib/cli.js to coverage tests
#129
Expose notebook.errors in console reporter
#128
Refactor to test lab with lab
#126
Checking leaks on non-enumerable properties
#124
4.0 Breaking Change
#123
Add new ES6 types to knownGlobals
#117
"Infinite" Timeout
#116
Add describe.skip/only and it.skip/only
#113
Repeat failure count at end of errors listing.
#110
Lab.test.only and Lab.test.skip
#108
Adding coverage tests skew the line-numbers in stack statements.
#107
Lab doesn't show the assertion message when an assertion fails
#104
Display Test duration once completed (even with errors)
#103
tests should fail if before etc call back with an error or crash
#100
Fix #99: ignore custom globals in leak detection
#98
Add total missing lines to the coverage reporter
#60
Add tests
#131
Rename spumko to hapijs
#96
simplify package.json example
#94
Add chai optional message to output
#90
Allow ability to execute specific subset of tests
#92
Prints execution time for each test on console
#91
Coverage file filter function modified to support Windows paths #32
#32
Coverage not working on Windows
#88
updated double call check on done to provide error to internals.output
#83
Ability to skip coverage for a code section
#81
Add command like option to force color output
#78
Support passing 'done' as async callback
#77
Show error message not just for boom
#76
Expose Chai's assert flavour. Closes #75.
3.0.0
breaking changes
#70
Skip test or experiment
#69
Allow setting per test of experiment timeout
#68
Allow setting parallel execution
#67
Combine spec+console+summary with -s/-v flags
#66
before/beforeEach/afterEach/after not run in correct order when using nested experiments
#65
Rename -g to -l and make it disable detection
#64
Remove coverage reporter
#63
Remove verbose mode
#62
Tap reporter
#56
spec style formatting
#55
fixed failure count so that non-zero exit code is return on test failure
#53
Support verbose mode for console
#48
Adding spec reporter
#61
Remove SwitchCase from statement coverage
2.0.0
breaking changes
#54
Move coverage functionality internally
#51
update chai dependency, fix deprecation warning in chai
#49
Allow specifying tests by id
#41
Support beforeEach() (and afterEach())
#47
Fixed branch checking
#46
update readme
#45
Fix double domain implicit enter()
#43
fix for readme
#42
add beforeEach() and afterEach()
clipboard