From eeb006ec6e458b2b710c6a6cbeac65b9d9e13898 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 17 May 2016 17:57:09 -0500 Subject: [PATCH 01/42] Better documentation for schedule --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 970f0e6e..b1a98964 100755 --- a/README.md +++ b/README.md @@ -239,7 +239,7 @@ lab.experiment('math', { timeout: 1000 }, () => { The `script([options])` method takes an optional `options` argument where `options` is an 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 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`. Defaults to `true`. + 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 From be85ecf27d2dd13f30c7c06d274e978b46ac9bd9 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 17 May 2016 18:51:35 -0500 Subject: [PATCH 02/42] Don't execute before/after on expirements that lack tests --- lib/runner.js | 25 ++++++++++++++++++- test/runner.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/lib/runner.js b/lib/runner.js index f7a302b9..11270c10 100755 --- a/lib/runner.js +++ b/lib/runner.js @@ -256,7 +256,7 @@ internals.executeExperiments = function (experiments, state, skip, callback) { const previousDomains = state.domains; state.domains = []; - const skipExperiment = skip || experiment.options.skip; + const skipExperiment = skip || experiment.options.skip || !internals.experirementHasTests(experiment, state); const steps = [ function (next) { @@ -461,6 +461,29 @@ internals.executeTests = function (experiment, state, skip, callback) { }; +internals.experirementHasTests = function (experiment, state) { + + if (experiment.experiments.length) { + return true; + } + + const tests = experiment.tests.filter((test) => { + + if ((state.filters.ids.length && state.filters.ids.indexOf(test.id) === -1) || + (state.filters.grep && !state.filters.grep.test(test.title))) { + + return; + } + + if (!test.options.skip && test.fn) { + return test; + } + }); + + return tests.length; +}; + + internals.collectDeps = function (experiment, key) { const set = []; diff --git a/test/runner.js b/test/runner.js index 13fa2551..a3c6cdc1 100755 --- a/test/runner.js +++ b/test/runner.js @@ -678,6 +678,71 @@ describe('Runner', () => { }); }); + it('skips before function in non-run experiment', (done) => { + + const script = Lab.script(); + script.experiment('test', () => { + + script.experiment.skip('subexperiment1', () => { + + script.before((beforeDone) => { + + throw new Error(); + }); + + script.test('s1', (testDone) => testDone()); + }); + + script.experiment('subexperiment2', () => { + + script.before((beforeDone) => beforeDone()); + + script.test('s1', (testDone) => testDone()); + }); + }); + + Lab.execute(script, {}, null, (err, notebook) => { + + expect(err).not.to.exist(); + expect(notebook.tests).to.have.length(2); + expect(notebook.tests.filter((test) => test.skipped)).to.have.length(1); + expect(notebook.failures).to.equal(0); + done(); + }); + }); + + it('skips before function when not run through index', (done) => { + + const script = Lab.script(); + script.experiment('test', () => { + + script.experiment('subexperiment1', () => { + + script.before((beforeDone) => { + + throw new Error(); + }); + + script.test('s1', (testDone) => testDone()); + }); + + script.experiment('subexperiment2', () => { + + script.before((beforeDone) => beforeDone()); + + script.test('s1', (testDone) => testDone()); + }); + }); + + Lab.execute(script, { ids: [2] }, null, (err, notebook) => { + + expect(err).not.to.exist(); + expect(notebook.tests).to.have.length(1); + expect(notebook.failures).to.equal(0); + done(); + }); + }); + it('dry run', (done) => { const script = Lab.script(); From 772a7bfe997ca8a648ca5047f643ad9cc5421128 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 17 May 2016 19:03:22 -0500 Subject: [PATCH 03/42] Typo --- lib/runner.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/runner.js b/lib/runner.js index 11270c10..d5865b09 100755 --- a/lib/runner.js +++ b/lib/runner.js @@ -256,7 +256,7 @@ internals.executeExperiments = function (experiments, state, skip, callback) { const previousDomains = state.domains; state.domains = []; - const skipExperiment = skip || experiment.options.skip || !internals.experirementHasTests(experiment, state); + const skipExperiment = skip || experiment.options.skip || !internals.experimentHasTests(experiment, state); const steps = [ function (next) { @@ -461,7 +461,7 @@ internals.executeTests = function (experiment, state, skip, callback) { }; -internals.experirementHasTests = function (experiment, state) { +internals.experimentHasTests = function (experiment, state) { if (experiment.experiments.length) { return true; From a6f12b79ee6915108d9398afdb38ad0bdb71e247 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 17 May 2016 19:25:43 -0500 Subject: [PATCH 04/42] Make boolean on return type --- lib/runner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runner.js b/lib/runner.js index d5865b09..3e575bc8 100755 --- a/lib/runner.js +++ b/lib/runner.js @@ -480,7 +480,7 @@ internals.experimentHasTests = function (experiment, state) { } }); - return tests.length; + return !!tests.length; }; From cfe38f38e1259644f8111d07cbe8c6dc344529a7 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 17 May 2016 19:40:15 -0500 Subject: [PATCH 05/42] Recurse through experiment chain --- lib/runner.js | 9 ++++++++- test/runner.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/lib/runner.js b/lib/runner.js index 3e575bc8..3b2541f9 100755 --- a/lib/runner.js +++ b/lib/runner.js @@ -464,7 +464,14 @@ internals.executeTests = function (experiment, state, skip, callback) { internals.experimentHasTests = function (experiment, state) { if (experiment.experiments.length) { - return true; + const experimentsWithTests = experiment.experiments.filter((childExperiment) => { + + return internals.experimentHasTests(childExperiment, state); + }); + + if (experimentsWithTests.length) { + return true; + } } const tests = experiment.tests.filter((test) => { diff --git a/test/runner.js b/test/runner.js index a3c6cdc1..041d29a8 100755 --- a/test/runner.js +++ b/test/runner.js @@ -743,6 +743,49 @@ describe('Runner', () => { }); }); + it('skips before function when not run through index and in sub experiment', (done) => { + + const script = Lab.script(); + script.experiment('test', () => { + + script.experiment('subexperiment1', () => { + + script.before((beforeDone) => { + + throw new Error(); + }); + + script.experiment('sub sub experiment1', () => { + + script.before((beforeDone) => { + + throw new Error(); + }); + + script.test('s1', (testDone) => testDone()); + }); + }); + + script.experiment('subexperiment2', () => { + + script.experiment('sub subexperiment2', () => { + + script.before((beforeDone) => beforeDone()); + + script.test('s1', (testDone) => testDone()); + }); + }); + }); + + Lab.execute(script, { ids: [2] }, null, (err, notebook) => { + + expect(err).not.to.exist(); + expect(notebook.tests).to.have.length(1); + expect(notebook.failures).to.equal(0); + done(); + }); + }); + it('dry run', (done) => { const script = Lab.script(); From 069ec6b5023167d33e92beaa2ce382a286181228 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 17 May 2016 22:21:41 -0500 Subject: [PATCH 06/42] Document how to only run linting --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index b1a98964..14bc6951 100755 --- a/README.md +++ b/README.md @@ -359,12 +359,22 @@ if (typeof value === 'symbol') { Your project's eslint configuration will now extend the default **lab** configuration. ## Ignoring files in linting + Since [eslint](http://eslint.org/) 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 +``` + ## Running a custom linter If you would like to run a different linter, or even a custom version of eslint you should From 29865fda736e9ecdfa4cbcb0689e0f2e54a58a81 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 17 May 2016 22:52:32 -0500 Subject: [PATCH 07/42] Default output to stdout --- lib/runner.js | 2 +- test/index.js | 2 +- test/reporters.js | 100 +++++++++++++++++++++++----------------------- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/lib/runner.js b/lib/runner.js index f7a302b9..8ea396cd 100755 --- a/lib/runner.js +++ b/lib/runner.js @@ -45,7 +45,7 @@ internals.defaults = { globals: null, leaks: true, timeout: 2000, - output: false, // Stream.Writable or string (filename) + output: process.stdout, // Stream.Writable or string (filename) parallel: false, progress: 1, reporter: 'console', diff --git a/test/index.js b/test/index.js index 8f52357b..bd143e7e 100755 --- a/test/index.js +++ b/test/index.js @@ -775,7 +775,7 @@ describe('Lab', () => { it('schedules automatic execution', { parallel: false }, (done) => { - const script = Lab.script(); + const script = Lab.script({ output: false }); script.experiment('test', () => { script.test('works', (testDone) => { diff --git a/test/reporters.js b/test/reporters.js index aa68df62..211a855b 100755 --- a/test/reporters.js +++ b/test/reporters.js @@ -339,7 +339,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console' }, (err, code, output) => { + Lab.report(script, { reporter: 'console', output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(0); @@ -361,7 +361,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -392,7 +392,7 @@ describe('Reporter', () => { script.test('a todo test'); }); - Lab.report(script, { reporter: 'console' }, (err, code, output) => { + Lab.report(script, { reporter: 'console', output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(0); @@ -417,7 +417,7 @@ describe('Reporter', () => { }); global.x1 = true; - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { delete global.x1; expect(err).to.not.exist(); @@ -441,7 +441,7 @@ describe('Reporter', () => { }); global.x1 = true; - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { delete global.x1; expect(err).to.not.exist(); @@ -468,7 +468,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false, leaks: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, leaks: false, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -492,7 +492,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false, leaks: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, leaks: false, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -516,7 +516,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false, leaks: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, leaks: false, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -540,7 +540,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false, leaks: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, leaks: false, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -562,7 +562,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -582,7 +582,7 @@ describe('Reporter', () => { script.test('works', (finished) => { }); }); - Lab.report(script, { reporter: 'console', colors: false, timeout: 1 }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, timeout: 1, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -625,7 +625,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false, 'context-timeout': 1 }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, 'context-timeout': 1, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -650,7 +650,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false, 'context-timeout': 1000 }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, 'context-timeout': 1000, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(0); @@ -670,7 +670,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -692,7 +692,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', progress: 0 }, (err, code, output) => { + Lab.report(script, { reporter: 'console', progress: 0, output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.match(/^\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/); @@ -711,7 +711,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', progress: 2 }, (err, code, output) => { + Lab.report(script, { reporter: 'console', progress: 2, output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.match(/^test\n \u001b\[32m✔\u001b\[0m \u001b\[90m1\) works \(\d+ ms\)\u001b\[0m\n\n\n\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/); @@ -731,7 +731,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', progress: 2, assert: Code }, (err, code, output) => { + Lab.report(script, { reporter: 'console', progress: 2, assert: Code, output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.match(/^test\n \u001b\[32m✔\u001b\[0m \u001b\[90m1\) works \(\d+ ms and \d+ assertions\)\u001b\[0m\n\n\n\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\nAssertions count\: \d+ \(verbosity\: \d+\.\d+\)\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/); @@ -753,7 +753,7 @@ describe('Reporter', () => { const oldPlatform = process.platform; Object.defineProperty(process, 'platform', { writable: true, value: 'win32' }); - Lab.report(script, { reporter: 'console', progress: 2 }, (err, code, output) => { + Lab.report(script, { reporter: 'console', progress: 2, output: false }, (err, code, output) => { process.platform = oldPlatform; expect(err).not.to.exist(); @@ -782,7 +782,7 @@ describe('Reporter', () => { script.test('a todo test'); }); - Lab.report(script, { reporter: 'console', 'silent-skips': true }, (err, code, output) => { + Lab.report(script, { reporter: 'console', 'silent-skips': true, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(0); @@ -814,7 +814,7 @@ describe('Reporter', () => { script.test('a todo test'); }); - Lab.report(script, { reporter: 'console', progress: 2, 'silent-skips': true }, (err, code, output) => { + Lab.report(script, { reporter: 'console', progress: 2, 'silent-skips': true, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(0); @@ -850,7 +850,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', coverage: true, coveragePath: Path.join(__dirname, './coverage/console') }, (err, code, output) => { + Lab.report(script, { reporter: 'console', coverage: true, coveragePath: Path.join(__dirname, './coverage/console'), output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.contain('Coverage: 80.95% (4/21)'); @@ -893,7 +893,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', coverage: true, coveragePath: Path.join(__dirname, './coverage/sourcemaps-external'), sourcemaps: true }, (err, code, output) => { + Lab.report(script, { reporter: 'console', coverage: true, coveragePath: Path.join(__dirname, './coverage/sourcemaps-external'), sourcemaps: true, output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.contain('test/coverage/sourcemaps-external.js missing coverage from file(s):'); @@ -916,7 +916,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', coverage: true, coveragePath: Path.join(__dirname, './coverage/'), sourcemaps: true }, (err, code, output) => { + Lab.report(script, { reporter: 'console', coverage: true, coveragePath: Path.join(__dirname, './coverage/'), sourcemaps: true, output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.not.contain('sourcemaps-covered'); @@ -953,7 +953,7 @@ describe('Reporter', () => { } }); - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -983,7 +983,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false, progress: 2 }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, progress: 2, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -1011,7 +1011,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console' }, (err, code, output) => { + Lab.report(script, { reporter: 'console', output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(0); @@ -1032,7 +1032,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { expect(err).not.to.exist(); const result = output.replace(/at.*\.js\:\d+\:\d+\)?/g, 'at '); @@ -1058,7 +1058,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { expect(err).not.to.exist(); @@ -1088,7 +1088,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { expect(err).not.to.exist(); @@ -1196,7 +1196,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { expect(err).not.to.exist(); const result = output.replace(/at.*\.js\:\d+\:\d+\)?/g, 'at '); @@ -1228,7 +1228,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'console', colors: false }, (err, code, output) => { + Lab.report(script, { reporter: 'console', colors: false, output: false }, (err, code, output) => { expect(err).not.to.exist(); const result = output.replace(/at.*\.js\:\d+\:\d+\)?/g, 'at '); @@ -1263,7 +1263,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'json', lint: true, linter: 'eslint' }, (err, code, output) => { + Lab.report(script, { reporter: 'json', lint: true, linter: 'eslint', output: false }, (err, code, output) => { const result = JSON.parse(output); expect(err).to.not.exist(); @@ -1301,7 +1301,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'json' }, (err, code, output) => { + Lab.report(script, { reporter: 'json', output: false }, (err, code, output) => { const result = JSON.parse(output); expect(err).to.not.exist(); @@ -1326,7 +1326,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'json', coverage: true, coveragePath: Path.join(__dirname, './coverage/json') }, (err, code, output) => { + Lab.report(script, { reporter: 'json', coverage: true, coveragePath: Path.join(__dirname, './coverage/json'), output: false }, (err, code, output) => { expect(err).not.to.exist(); const result = JSON.parse(output); @@ -1352,7 +1352,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'html', coverage: true, coveragePath: Path.join(__dirname, './coverage/html') }, (err, code, output) => { + Lab.report(script, { reporter: 'html', coverage: true, coveragePath: Path.join(__dirname, './coverage/html'), output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.contain('
'); @@ -1376,7 +1376,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'html', coverage: true, coveragePath: Path.join(__dirname, './coverage/sourcemaps-external'), sourcemaps: true }, (err, code, output) => { + Lab.report(script, { reporter: 'html', coverage: true, coveragePath: Path.join(__dirname, './coverage/sourcemaps-external'), sourcemaps: true, output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.contain([ @@ -1417,7 +1417,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'html', coverage: true, coveragePath: Path.join(__dirname, './coverage/html-lint/'), lint: true, linter: 'eslint', lintingPath: Path.join(__dirname, './coverage/html-lint') }, (err, code, output) => { + Lab.report(script, { reporter: 'html', coverage: true, coveragePath: Path.join(__dirname, './coverage/html-lint/'), lint: true, linter: 'eslint', lintingPath: Path.join(__dirname, './coverage/html-lint'), output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output) @@ -1461,7 +1461,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'html', coverage: true, coveragePath: Path.join(__dirname, './coverage/html-lint/'), lint: true, linter: 'eslint', lintingPath: Path.join(__dirname, './coverage/html-lint'), 'lint-errors-threshold': 2, 'lint-warnings-threshold': 2 }, (err, code, output) => { + Lab.report(script, { reporter: 'html', coverage: true, coveragePath: Path.join(__dirname, './coverage/html-lint/'), lint: true, linter: 'eslint', lintingPath: Path.join(__dirname, './coverage/html-lint'), 'lint-errors-threshold': 2, 'lint-warnings-threshold': 2, output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output) @@ -1485,7 +1485,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'html', 'context-timeout': 1 }, (err, code, output) => { + Lab.report(script, { reporter: 'html', 'context-timeout': 1, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -1512,7 +1512,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'html', 'context-timeout': 1 }, (err, code, output) => { + Lab.report(script, { reporter: 'html', 'context-timeout': 1, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -1628,7 +1628,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'html', coveragePath: Path.join(__dirname, './coverage/html') }, (err, code, output) => { + Lab.report(script, { reporter: 'html', coveragePath: Path.join(__dirname, './coverage/html'), output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.contain('Test Report'); @@ -1671,7 +1671,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'tap' }, (err, code, output) => { + Lab.report(script, { reporter: 'tap', output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -1714,7 +1714,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'junit' }, (err, code, output) => { + Lab.report(script, { reporter: 'junit', output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(1); @@ -1747,7 +1747,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'lcov', coverage: true }, (err, code, output) => { + Lab.report(script, { reporter: 'lcov', coverage: true, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(0); @@ -1776,7 +1776,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'lcov', coverage: false }, (err, code, output) => { + Lab.report(script, { reporter: 'lcov', coverage: false, output: false }, (err, code, output) => { expect(err).to.not.exist(); expect(code).to.equal(0); @@ -1812,7 +1812,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'clover', coverage: true, coveragePath: Path.join(__dirname, './coverage/clover') }, (err, code, output) => { + Lab.report(script, { reporter: 'clover', coverage: true, coveragePath: Path.join(__dirname, './coverage/clover'), output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.contain('clover.test.coverage'); @@ -1852,7 +1852,7 @@ describe('Reporter', () => { const origCwd = process.cwd(); process.chdir(Path.join(__dirname, './coverage/')); - Lab.report(script, { reporter: 'clover', coverage: true, coveragePath: Path.join(__dirname, './coverage/clover') }, (err, code, output) => { + Lab.report(script, { reporter: 'clover', coverage: true, coveragePath: Path.join(__dirname, './coverage/clover'), output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.not.contain('clover.test.coverage'); @@ -1894,7 +1894,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: 'clover', coverage: false, coveragePath: Path.join(__dirname, './coverage/clover') }, (err, code, output) => { + Lab.report(script, { reporter: 'clover', coverage: false, coveragePath: Path.join(__dirname, './coverage/clover'), output: false }, (err, code, output) => { expect(err).not.to.exist(); expect(output).to.not.contain('clover.test.coverage'); @@ -2031,7 +2031,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: reporter }, (err, code, output) => { + Lab.report(script, { reporter: reporter, output: false }, (err, code, output) => { expect(err).to.not.exist(); done(); @@ -2051,7 +2051,7 @@ describe('Reporter', () => { }); }); - Lab.report(script, { reporter: reporter }, (err, code, output) => { + Lab.report(script, { reporter: reporter, output: false }, (err, code, output) => { expect(err).to.not.exist(); done(); From e254f087a4973aa2f3205f556f2555d890c3255e Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Wed, 18 May 2016 09:40:20 -0500 Subject: [PATCH 08/42] Switch to some --- lib/runner.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/runner.js b/lib/runner.js index 3b2541f9..0ed770b0 100755 --- a/lib/runner.js +++ b/lib/runner.js @@ -464,30 +464,30 @@ internals.executeTests = function (experiment, state, skip, callback) { internals.experimentHasTests = function (experiment, state) { if (experiment.experiments.length) { - const experimentsWithTests = experiment.experiments.filter((childExperiment) => { + const experimentsHasTests = experiment.experiments.some((childExperiment) => { return internals.experimentHasTests(childExperiment, state); }); - if (experimentsWithTests.length) { + if (experimentsHasTests) { return true; } } - const tests = experiment.tests.filter((test) => { + const hasTests = experiment.tests.some((test) => { if ((state.filters.ids.length && state.filters.ids.indexOf(test.id) === -1) || (state.filters.grep && !state.filters.grep.test(test.title))) { - return; + return false; } if (!test.options.skip && test.fn) { - return test; + return true; } }); - return !!tests.length; + return hasTests; }; From 90f4879768c154258e8dd631a98bdffc84a028c6 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Wed, 18 May 2016 19:59:11 -0500 Subject: [PATCH 09/42] version 10.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 735ce202..e0f7e67c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lab", "description": "Test utility", - "version": "10.5.1", + "version": "10.6.0", "repository": "git://github.com/hapijs/lab", "main": "lib/index.js", "keywords": [ From 4e8f792ad8c72078fb5ecaec3efd210be72f72ce Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Wed, 18 May 2016 20:43:10 -0500 Subject: [PATCH 10/42] Support the same test name in diff experiments (#587) * Support the same test name in diff experiments * Allow duplicate named tests in different experiments to show --- lib/reporters/console.js | 2 +- test/reporters.js | 64 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/lib/reporters/console.js b/lib/reporters/console.js index c2fe6782..26033e97 100755 --- a/lib/reporters/console.js +++ b/lib/reporters/console.js @@ -69,7 +69,7 @@ internals.Reporter.prototype.test = function (test) { // Verbose (Spec reporter) for (let i = 0; i < test.path.length; ++i) { - if (test.path[i] !== this.last[i]) { + if (test.path[i] !== this.last[i] || (i > 0 && test.path[i - 1] !== this.last[i - 1])) { this.report(internals.spacer(i * 2) + test.path[i] + '\n'); } } diff --git a/test/reporters.js b/test/reporters.js index 211a855b..be6373cb 100755 --- a/test/reporters.js +++ b/test/reporters.js @@ -719,6 +719,70 @@ describe('Reporter', () => { }); }); + it('generates a report with verbose progress with experiments with same named tests', (done) => { + + const script = Lab.script(); + script.experiment('experiment', () => { + + script.experiment('sub experiment', () => { + + script.experiment('sub sub experiment', () => { + + script.test('works', (finished) => finished()); + }); + }); + + script.experiment('sub experiment', () => { + + script.experiment('sub sub experiment', () => { + + script.test('works', (finished) => finished()); + }); + }); + + script.experiment('sub experiment', () => { + + script.experiment('sub sub experiment 1', () => { + + script.experiment('sub sub sub experiment', () => { + + script.test('works', (finished) => finished()); + }); + }); + + script.experiment('sub sub experiment', () => { + + script.experiment('sub sub sub experiment', () => { + + script.test('works', (finished) => finished()); + }); + }); + }); + }); + + Lab.report(script, { reporter: 'console', progress: 2, output: false }, (err, code, output) => { + + expect(err).not.to.exist(); + expect(output).to.contain('4) works'); + done(); + }); + }); + + it('generates a report with verbose progress with the same test name and no wrapper experiment', (done) => { + + const script = Lab.script(); + script.test('works', (finished) => finished()); + script.test('works', (finished) => finished()); + + Lab.report(script, { reporter: 'console', progress: 2, output: false }, (err, code, output) => { + + expect(err).not.to.exist(); + expect(output).to.contain('1) works'); + expect(output).to.contain('2) works'); + done(); + }); + }); + it('generates a report with verbose progress and assertions count per test', (done) => { const script = Lab.script(); From 7db37f616ca7302a1dbe23d9561a2d8d4637e4aa Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Wed, 18 May 2016 21:19:27 -0500 Subject: [PATCH 11/42] Make coverage excludes more explicit --- lib/cli.js | 2 +- lib/coverage.js | 3 ++- test/cli.js | 2 +- test/coverage.js | 10 ++++++++++ test/coverage/test-folder/test-name.js | 14 ++++++++++++++ 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 test/coverage/test-folder/test-name.js diff --git a/lib/cli.js b/lib/cli.js index e3fac10a..6c394697 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -23,7 +23,7 @@ exports.run = function () { const settings = internals.options(); settings.coveragePath = Path.join(process.cwd(), settings['coverage-path'] || ''); - settings.coverageExclude = ['node_modules', 'test']; + settings.coverageExclude = ['node_modules', 'test', 'test_runner']; if (settings['coverage-exclude']) { settings.coverageExclude = settings.coverageExclude.concat(settings['coverage-exclude']); } diff --git a/lib/coverage.js b/lib/coverage.js index 39639aef..31a18fc1 100755 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -49,7 +49,8 @@ exports.instrument = function (options) { internals.pattern = function (options) { const base = internals.escape(options.coveragePath || ''); - const excludes = options.coverageExclude ? [].concat(options.coverageExclude).map(internals.escape).join('|') : ''; + let excludes = options.coverageExclude ? [].concat(options.coverageExclude).map(internals.escape) : ''; + excludes = excludes ? excludes.map((exclude) => `${exclude}\\/`).join('|') : excludes; const regex = '^' + base + (excludes ? (base[base.length - 1] === '/' ? '' : '\\/') + '(?!' + excludes + ')' : ''); return new RegExp(regex); }; diff --git a/test/cli.js b/test/cli.js index 8be7e62c..057e54b2 100755 --- a/test/cli.js +++ b/test/cli.js @@ -395,7 +395,7 @@ describe('CLI', () => { it('doesn\'t fail with coverage when no external file is being tested', (done) => { - RunCli(['test/cli/simple.js', '-t', '10'], (error, result) => { + RunCli(['test/cli/simple.js', '-t', '100'], (error, result) => { if (error) { done(error); diff --git a/test/coverage.js b/test/coverage.js index 23bb5a24..bbc42def 100755 --- a/test/coverage.js +++ b/test/coverage.js @@ -59,6 +59,16 @@ describe('Coverage', () => { done(); }); + it('measures coverage a file with test in the name', (done) => { + + const Test = require('./coverage/test-folder/test-name.js'); + Test.method(); + + const cov = Lab.coverage.analyze({ coveragePath: Path.join(__dirname, 'coverage/test-folder'), coverageExclude: ['test', 'node_modules'] }); + expect(cov.percent).to.equal(100); + done(); + }); + it('identifies lines with partial coverage when having external sourcemap', (done) => { const Test = require('./coverage/sourcemaps-external'); diff --git a/test/coverage/test-folder/test-name.js b/test/coverage/test-folder/test-name.js new file mode 100644 index 00000000..84e87723 --- /dev/null +++ b/test/coverage/test-folder/test-name.js @@ -0,0 +1,14 @@ +'use strict'; + +// Load modules + + +// Declare internals + +const internals = {}; + + +exports.method = function () { + + return; +}; From b185e0c22e2e0b09b8770e44f02c7bacc226083e Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Thu, 19 May 2016 09:16:06 -0500 Subject: [PATCH 12/42] Make coverage excludes more explicit (#588) --- lib/cli.js | 2 +- lib/coverage.js | 3 ++- test/cli.js | 2 +- test/coverage.js | 10 ++++++++++ test/coverage/test-folder/test-name.js | 14 ++++++++++++++ 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 test/coverage/test-folder/test-name.js diff --git a/lib/cli.js b/lib/cli.js index e3fac10a..6c394697 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -23,7 +23,7 @@ exports.run = function () { const settings = internals.options(); settings.coveragePath = Path.join(process.cwd(), settings['coverage-path'] || ''); - settings.coverageExclude = ['node_modules', 'test']; + settings.coverageExclude = ['node_modules', 'test', 'test_runner']; if (settings['coverage-exclude']) { settings.coverageExclude = settings.coverageExclude.concat(settings['coverage-exclude']); } diff --git a/lib/coverage.js b/lib/coverage.js index 39639aef..31a18fc1 100755 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -49,7 +49,8 @@ exports.instrument = function (options) { internals.pattern = function (options) { const base = internals.escape(options.coveragePath || ''); - const excludes = options.coverageExclude ? [].concat(options.coverageExclude).map(internals.escape).join('|') : ''; + let excludes = options.coverageExclude ? [].concat(options.coverageExclude).map(internals.escape) : ''; + excludes = excludes ? excludes.map((exclude) => `${exclude}\\/`).join('|') : excludes; const regex = '^' + base + (excludes ? (base[base.length - 1] === '/' ? '' : '\\/') + '(?!' + excludes + ')' : ''); return new RegExp(regex); }; diff --git a/test/cli.js b/test/cli.js index 8be7e62c..057e54b2 100755 --- a/test/cli.js +++ b/test/cli.js @@ -395,7 +395,7 @@ describe('CLI', () => { it('doesn\'t fail with coverage when no external file is being tested', (done) => { - RunCli(['test/cli/simple.js', '-t', '10'], (error, result) => { + RunCli(['test/cli/simple.js', '-t', '100'], (error, result) => { if (error) { done(error); diff --git a/test/coverage.js b/test/coverage.js index 23bb5a24..bbc42def 100755 --- a/test/coverage.js +++ b/test/coverage.js @@ -59,6 +59,16 @@ describe('Coverage', () => { done(); }); + it('measures coverage a file with test in the name', (done) => { + + const Test = require('./coverage/test-folder/test-name.js'); + Test.method(); + + const cov = Lab.coverage.analyze({ coveragePath: Path.join(__dirname, 'coverage/test-folder'), coverageExclude: ['test', 'node_modules'] }); + expect(cov.percent).to.equal(100); + done(); + }); + it('identifies lines with partial coverage when having external sourcemap', (done) => { const Test = require('./coverage/sourcemaps-external'); diff --git a/test/coverage/test-folder/test-name.js b/test/coverage/test-folder/test-name.js new file mode 100644 index 00000000..84e87723 --- /dev/null +++ b/test/coverage/test-folder/test-name.js @@ -0,0 +1,14 @@ +'use strict'; + +// Load modules + + +// Declare internals + +const internals = {}; + + +exports.method = function () { + + return; +}; From e875eac2bd5d9b9adf596cfe20b10bd04f2898bf Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Fri, 20 May 2016 21:48:42 -0500 Subject: [PATCH 13/42] Update to code v3 --- package.json | 2 +- test/coverage.js | 16 ++++++++-------- test/linters.js | 8 ++++---- test/reporters.js | 2 +- test/runner.js | 14 +++++++------- test/utils.js | 10 +++++----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index e0f7e67c..93519075 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "source-map-support": "0.4.x" }, "devDependencies": { - "code": "2.x.x", + "code": "3.x.x", "cpr": "1.1.x", "eslint-plugin-markdown": "1.0.0-beta.2", "lab-event-reporter": "1.x.x", diff --git a/test/coverage.js b/test/coverage.js index bbc42def..acfa9f08 100755 --- a/test/coverage.js +++ b/test/coverage.js @@ -90,7 +90,7 @@ describe('Coverage', () => { } }); - expect(missedLines).to.deep.include([ + expect(missedLines).to.include([ { filename: 'test/coverage/while.js', lineNumber: '5', originalLineNumber: 11 }, { filename: 'test/coverage/while.js', lineNumber: '6', originalLineNumber: 12 } ]); @@ -119,7 +119,7 @@ describe('Coverage', () => { } }); - expect(missedLines).to.deep.include([ + expect(missedLines).to.include([ { filename: './while.js', lineNumber: '5', originalLineNumber: 11 }, { filename: './while.js', lineNumber: '6', originalLineNumber: 12 } ]); @@ -209,7 +209,7 @@ describe('Coverage', () => { it('should work with loop labels', (done) => { const Test = require('./coverage/loop-labels.js'); - expect(Test.method()).to.deep.equal([1, 0]); + expect(Test.method()).to.equal([1, 0]); const cov = Lab.coverage.analyze({ coveragePath: Path.join(__dirname, 'coverage/loop-labels') }); const source = cov.files[0].source; @@ -225,7 +225,7 @@ describe('Coverage', () => { } }); - expect(missedChunks).to.have.length(1).and.to.deep.equal([{ source: 'j < 1', miss: 'true' }]); + expect(missedChunks).to.have.length(1).and.to.equal([{ source: 'j < 1', miss: 'true' }]); done(); }); @@ -245,8 +245,8 @@ describe('Coverage', () => { const cov = Lab.coverage.analyze({ coveragePath: Path.join(__dirname, 'coverage/single-line-functions') }); const source = cov.files[0].source; const missedLines = Object.keys(source).filter((lineNumber) => source[lineNumber].miss); - expect(results).to.deep.equal([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 10, 5]); - expect(missedLines).to.deep.equal(['12', '15', '21', '27', '30', '33', '39', '46', '50', '53', '56']); + expect(results).to.equal([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 10, 5]); + expect(missedLines).to.equal(['12', '15', '21', '27', '30', '33', '39', '46', '50', '53', '56']); done(); }); @@ -259,7 +259,7 @@ describe('Coverage', () => { const source = cov.files[0].source; const missedLines = Object.keys(source).filter((lineNumber) => source[lineNumber].miss); expect(result).to.equal(7); - expect(missedLines).to.deep.equal(['19', '22']); + expect(missedLines).to.equal(['19', '22']); done(); }); @@ -280,7 +280,7 @@ describe('Coverage', () => { return file.filename; }); - expect(sorted).to.deep.equal(['/a/b', '/a/c', '/a/b/a', '/a/b/c', '/a/c/b']); + expect(sorted).to.equal(['/a/b', '/a/c', '/a/b/a', '/a/b/c', '/a/c/b']); done(); }); }); diff --git a/test/linters.js b/test/linters.js index 758844dc..04a5bb95 100755 --- a/test/linters.js +++ b/test/linters.js @@ -31,7 +31,7 @@ describe('Linters - eslint', () => { const checkedFile = eslintResults[0]; expect(checkedFile).to.include({ filename: Path.join(path, 'fail.js') }); - expect(checkedFile.errors).to.deep.include([ + expect(checkedFile.errors).to.include([ { line: 13, severity: 'ERROR', message: 'semi - Missing semicolon.' }, { line: 14, severity: 'WARNING', message: 'eol-last - Newline required at end of file but not found.' } ]); @@ -53,7 +53,7 @@ describe('Linters - eslint', () => { const checkedFile = eslintResults[0]; expect(checkedFile).to.include({ filename: Path.join(path, 'fail.js') }); - expect(checkedFile.errors).to.deep.include([ + expect(checkedFile.errors).to.include([ { line: 13, severity: 'ERROR', message: 'semi - Missing semicolon.' }, { line: 14, severity: 'WARNING', message: 'eol-last - Newline required at end of file but not found.' } ]); @@ -75,9 +75,9 @@ describe('Linters - eslint', () => { const checkedFile = eslintResults[0]; expect(checkedFile).to.include({ filename: Path.join(path, 'fail.js') }); - expect(checkedFile.errors).to.deep.include([ + expect(checkedFile.errors).to.include([ { line: 14, severity: 'ERROR', message: 'eol-last - Newline required at end of file but not found.' }]); - expect(checkedFile.errors).to.not.deep.include({ line: 8, severity: 'ERROR', message: 'no-unused-vars - internals is defined but never used' }); + expect(checkedFile.errors).to.not.include({ line: 8, severity: 'ERROR', message: 'no-unused-vars - internals is defined but never used' }); done(); }); }); diff --git a/test/reporters.js b/test/reporters.js index be6373cb..0a235487 100755 --- a/test/reporters.js +++ b/test/reporters.js @@ -435,7 +435,7 @@ describe('Reporter', () => { script.test('works', (finished) => { - expect(['a', 'b']).to.deep.equal(['a', 'c']); + expect(['a', 'b']).to.equal(['a', 'c']); finished(); }); }); diff --git a/test/runner.js b/test/runner.js index 041d29a8..ba1e4847 100755 --- a/test/runner.js +++ b/test/runner.js @@ -911,7 +911,7 @@ describe('Runner', () => { Lab.execute(scripts, { dry: true, shuffle: true }, null, (err, notebook2) => { expect(err).not.to.exist(); - expect(notebook1.tests).to.not.deep.equal(notebook2.tests); + expect(notebook1.tests).to.not.equal(notebook2.tests); Math.random = random; done(); }); @@ -982,7 +982,7 @@ describe('Runner', () => { expect(err).to.not.exist(); expect(notebook.tests[0].err).to.equal('\'before\' action failed'); - expect(steps).to.deep.equal(['before']); + expect(steps).to.equal(['before']); done(); }); }); @@ -1016,7 +1016,7 @@ describe('Runner', () => { expect(err).to.not.exist(); expect(notebook.tests[0].err).to.equal('\'before each\' action failed'); - expect(steps).to.deep.equal(['before']); + expect(steps).to.equal(['before']); done(); }); }); @@ -1082,7 +1082,7 @@ describe('Runner', () => { Lab.execute(script, null, null, (err, notebook) => { expect(err).not.to.exist(); - expect(steps).to.deep.equal([ + expect(steps).to.equal([ 'outer beforeEach', 'first test', 'outer afterEach 1', @@ -1124,7 +1124,7 @@ describe('Runner', () => { Lab.execute(script, { parallel: true }, null, (err, notebook) => { expect(err).not.to.exist(); - expect(steps).to.deep.equal(['2', '1']); + expect(steps).to.equal(['2', '1']); done(); }); }); @@ -1154,7 +1154,7 @@ describe('Runner', () => { Lab.execute(script, { parallel: true }, null, (err, notebook) => { expect(err).not.to.exist(); - expect(steps).to.deep.equal(['1', '2']); + expect(steps).to.equal(['1', '2']); done(); }); }); @@ -1184,7 +1184,7 @@ describe('Runner', () => { Lab.execute(script, null, null, (err, notebook) => { expect(err).not.to.exist(); - expect(steps).to.deep.equal(['2', '1']); + expect(steps).to.equal(['2', '1']); done(); }); }); diff --git a/test/utils.js b/test/utils.js index 56ab0feb..af159108 100755 --- a/test/utils.js +++ b/test/utils.js @@ -35,7 +35,7 @@ describe('Utils', () => { }; const merged = Utils.mergeOptions(parent, child); - expect(merged).to.deep.equal({ a: 1, b: 3, c: 4 }); + expect(merged).to.equal({ a: 1, b: 3, c: 4 }); done(); }); @@ -47,7 +47,7 @@ describe('Utils', () => { }; const merged = Utils.mergeOptions(parent, null); - expect(merged).to.deep.equal({ a: 1, b: 2 }); + expect(merged).to.equal({ a: 1, b: 2 }); done(); }); @@ -59,7 +59,7 @@ describe('Utils', () => { }; const merged = Utils.mergeOptions(null, child); - expect(merged).to.deep.equal({ b: 3, c: 4 }); + expect(merged).to.equal({ b: 3, c: 4 }); done(); }); @@ -78,7 +78,7 @@ describe('Utils', () => { }; const merged = Utils.mergeOptions(parent, child, ['e', 'f']); - expect(merged).to.deep.equal({ a: 1, b: 3, c: 4 }); + expect(merged).to.equal({ a: 1, b: 3, c: 4 }); done(); }); @@ -97,7 +97,7 @@ describe('Utils', () => { }; Utils.applyOptions(parent, child); - expect(parent).to.deep.equal({ a: 1, b: 3, c: 4, e: 5, f: 6 }); + expect(parent).to.equal({ a: 1, b: 3, c: 4, e: 5, f: 6 }); done(); }); }); From 96c293733883535e6a65a8b4729381244698fbae Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Fri, 20 May 2016 21:51:49 -0500 Subject: [PATCH 14/42] Update to code v3 (#589) * Update to code v3 --- package.json | 2 +- test/coverage.js | 16 ++++++++-------- test/linters.js | 8 ++++---- test/reporters.js | 2 +- test/runner.js | 14 +++++++------- test/utils.js | 10 +++++----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index e0f7e67c..93519075 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "source-map-support": "0.4.x" }, "devDependencies": { - "code": "2.x.x", + "code": "3.x.x", "cpr": "1.1.x", "eslint-plugin-markdown": "1.0.0-beta.2", "lab-event-reporter": "1.x.x", diff --git a/test/coverage.js b/test/coverage.js index bbc42def..acfa9f08 100755 --- a/test/coverage.js +++ b/test/coverage.js @@ -90,7 +90,7 @@ describe('Coverage', () => { } }); - expect(missedLines).to.deep.include([ + expect(missedLines).to.include([ { filename: 'test/coverage/while.js', lineNumber: '5', originalLineNumber: 11 }, { filename: 'test/coverage/while.js', lineNumber: '6', originalLineNumber: 12 } ]); @@ -119,7 +119,7 @@ describe('Coverage', () => { } }); - expect(missedLines).to.deep.include([ + expect(missedLines).to.include([ { filename: './while.js', lineNumber: '5', originalLineNumber: 11 }, { filename: './while.js', lineNumber: '6', originalLineNumber: 12 } ]); @@ -209,7 +209,7 @@ describe('Coverage', () => { it('should work with loop labels', (done) => { const Test = require('./coverage/loop-labels.js'); - expect(Test.method()).to.deep.equal([1, 0]); + expect(Test.method()).to.equal([1, 0]); const cov = Lab.coverage.analyze({ coveragePath: Path.join(__dirname, 'coverage/loop-labels') }); const source = cov.files[0].source; @@ -225,7 +225,7 @@ describe('Coverage', () => { } }); - expect(missedChunks).to.have.length(1).and.to.deep.equal([{ source: 'j < 1', miss: 'true' }]); + expect(missedChunks).to.have.length(1).and.to.equal([{ source: 'j < 1', miss: 'true' }]); done(); }); @@ -245,8 +245,8 @@ describe('Coverage', () => { const cov = Lab.coverage.analyze({ coveragePath: Path.join(__dirname, 'coverage/single-line-functions') }); const source = cov.files[0].source; const missedLines = Object.keys(source).filter((lineNumber) => source[lineNumber].miss); - expect(results).to.deep.equal([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 10, 5]); - expect(missedLines).to.deep.equal(['12', '15', '21', '27', '30', '33', '39', '46', '50', '53', '56']); + expect(results).to.equal([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 5, 10, 5]); + expect(missedLines).to.equal(['12', '15', '21', '27', '30', '33', '39', '46', '50', '53', '56']); done(); }); @@ -259,7 +259,7 @@ describe('Coverage', () => { const source = cov.files[0].source; const missedLines = Object.keys(source).filter((lineNumber) => source[lineNumber].miss); expect(result).to.equal(7); - expect(missedLines).to.deep.equal(['19', '22']); + expect(missedLines).to.equal(['19', '22']); done(); }); @@ -280,7 +280,7 @@ describe('Coverage', () => { return file.filename; }); - expect(sorted).to.deep.equal(['/a/b', '/a/c', '/a/b/a', '/a/b/c', '/a/c/b']); + expect(sorted).to.equal(['/a/b', '/a/c', '/a/b/a', '/a/b/c', '/a/c/b']); done(); }); }); diff --git a/test/linters.js b/test/linters.js index 758844dc..04a5bb95 100755 --- a/test/linters.js +++ b/test/linters.js @@ -31,7 +31,7 @@ describe('Linters - eslint', () => { const checkedFile = eslintResults[0]; expect(checkedFile).to.include({ filename: Path.join(path, 'fail.js') }); - expect(checkedFile.errors).to.deep.include([ + expect(checkedFile.errors).to.include([ { line: 13, severity: 'ERROR', message: 'semi - Missing semicolon.' }, { line: 14, severity: 'WARNING', message: 'eol-last - Newline required at end of file but not found.' } ]); @@ -53,7 +53,7 @@ describe('Linters - eslint', () => { const checkedFile = eslintResults[0]; expect(checkedFile).to.include({ filename: Path.join(path, 'fail.js') }); - expect(checkedFile.errors).to.deep.include([ + expect(checkedFile.errors).to.include([ { line: 13, severity: 'ERROR', message: 'semi - Missing semicolon.' }, { line: 14, severity: 'WARNING', message: 'eol-last - Newline required at end of file but not found.' } ]); @@ -75,9 +75,9 @@ describe('Linters - eslint', () => { const checkedFile = eslintResults[0]; expect(checkedFile).to.include({ filename: Path.join(path, 'fail.js') }); - expect(checkedFile.errors).to.deep.include([ + expect(checkedFile.errors).to.include([ { line: 14, severity: 'ERROR', message: 'eol-last - Newline required at end of file but not found.' }]); - expect(checkedFile.errors).to.not.deep.include({ line: 8, severity: 'ERROR', message: 'no-unused-vars - internals is defined but never used' }); + expect(checkedFile.errors).to.not.include({ line: 8, severity: 'ERROR', message: 'no-unused-vars - internals is defined but never used' }); done(); }); }); diff --git a/test/reporters.js b/test/reporters.js index be6373cb..0a235487 100755 --- a/test/reporters.js +++ b/test/reporters.js @@ -435,7 +435,7 @@ describe('Reporter', () => { script.test('works', (finished) => { - expect(['a', 'b']).to.deep.equal(['a', 'c']); + expect(['a', 'b']).to.equal(['a', 'c']); finished(); }); }); diff --git a/test/runner.js b/test/runner.js index 041d29a8..ba1e4847 100755 --- a/test/runner.js +++ b/test/runner.js @@ -911,7 +911,7 @@ describe('Runner', () => { Lab.execute(scripts, { dry: true, shuffle: true }, null, (err, notebook2) => { expect(err).not.to.exist(); - expect(notebook1.tests).to.not.deep.equal(notebook2.tests); + expect(notebook1.tests).to.not.equal(notebook2.tests); Math.random = random; done(); }); @@ -982,7 +982,7 @@ describe('Runner', () => { expect(err).to.not.exist(); expect(notebook.tests[0].err).to.equal('\'before\' action failed'); - expect(steps).to.deep.equal(['before']); + expect(steps).to.equal(['before']); done(); }); }); @@ -1016,7 +1016,7 @@ describe('Runner', () => { expect(err).to.not.exist(); expect(notebook.tests[0].err).to.equal('\'before each\' action failed'); - expect(steps).to.deep.equal(['before']); + expect(steps).to.equal(['before']); done(); }); }); @@ -1082,7 +1082,7 @@ describe('Runner', () => { Lab.execute(script, null, null, (err, notebook) => { expect(err).not.to.exist(); - expect(steps).to.deep.equal([ + expect(steps).to.equal([ 'outer beforeEach', 'first test', 'outer afterEach 1', @@ -1124,7 +1124,7 @@ describe('Runner', () => { Lab.execute(script, { parallel: true }, null, (err, notebook) => { expect(err).not.to.exist(); - expect(steps).to.deep.equal(['2', '1']); + expect(steps).to.equal(['2', '1']); done(); }); }); @@ -1154,7 +1154,7 @@ describe('Runner', () => { Lab.execute(script, { parallel: true }, null, (err, notebook) => { expect(err).not.to.exist(); - expect(steps).to.deep.equal(['1', '2']); + expect(steps).to.equal(['1', '2']); done(); }); }); @@ -1184,7 +1184,7 @@ describe('Runner', () => { Lab.execute(script, null, null, (err, notebook) => { expect(err).not.to.exist(); - expect(steps).to.deep.equal(['2', '1']); + expect(steps).to.equal(['2', '1']); done(); }); }); diff --git a/test/utils.js b/test/utils.js index 56ab0feb..af159108 100755 --- a/test/utils.js +++ b/test/utils.js @@ -35,7 +35,7 @@ describe('Utils', () => { }; const merged = Utils.mergeOptions(parent, child); - expect(merged).to.deep.equal({ a: 1, b: 3, c: 4 }); + expect(merged).to.equal({ a: 1, b: 3, c: 4 }); done(); }); @@ -47,7 +47,7 @@ describe('Utils', () => { }; const merged = Utils.mergeOptions(parent, null); - expect(merged).to.deep.equal({ a: 1, b: 2 }); + expect(merged).to.equal({ a: 1, b: 2 }); done(); }); @@ -59,7 +59,7 @@ describe('Utils', () => { }; const merged = Utils.mergeOptions(null, child); - expect(merged).to.deep.equal({ b: 3, c: 4 }); + expect(merged).to.equal({ b: 3, c: 4 }); done(); }); @@ -78,7 +78,7 @@ describe('Utils', () => { }; const merged = Utils.mergeOptions(parent, child, ['e', 'f']); - expect(merged).to.deep.equal({ a: 1, b: 3, c: 4 }); + expect(merged).to.equal({ a: 1, b: 3, c: 4 }); done(); }); @@ -97,7 +97,7 @@ describe('Utils', () => { }; Utils.applyOptions(parent, child); - expect(parent).to.deep.equal({ a: 1, b: 3, c: 4, e: 5, f: 6 }); + expect(parent).to.equal({ a: 1, b: 3, c: 4, e: 5, f: 6 }); done(); }); }); From 71b927b57258a265107a62ba46a28053fb308785 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Fri, 20 May 2016 21:52:49 -0500 Subject: [PATCH 15/42] version 10.6.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93519075..f5601880 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lab", "description": "Test utility", - "version": "10.6.0", + "version": "10.6.1", "repository": "git://github.com/hapijs/lab", "main": "lib/index.js", "keywords": [ From e2b8e0fc305f1fd220637e5c3e9db72f974c01ad Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 23 May 2016 22:38:55 -0500 Subject: [PATCH 16/42] Support ability to add notes to a test --- README.md | 18 ++++++++++++++++++ lib/reporters/console.js | 20 ++++++++++++++++++++ lib/runner.js | 12 ++++++++++-- test/reporters.js | 22 ++++++++++++++++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14bc6951..35ca07ee 100755 --- a/README.md +++ b/README.md @@ -183,6 +183,24 @@ lab.experiment('with only', () => { }); ``` +The `test()` callback has a `note` function attached to it that can be used to +attach notes to the test case. These notes are included in the consoler 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: + +```javascript +lab.test('attaches notes', (done) => { + + Code.expect(1 + 1).to.equal(2); + done.note(`The current time is ${Date.now()}`); + done(); +}); +``` + +Multiple notes can be appended for the same test case by simply calling `note` +repeatedly. + + The `test()` callback provides a second `onCleanup` argument which is a function used to register a runtime cleanup function to be executed after the test completed. The cleanup function will execute even in the event of a timeout. Note that the cleanup function will be executed as-is without any timers and if it fails to call it's `next` argument, the runner will freeze. diff --git a/lib/reporters/console.js b/lib/reporters/console.js index 26033e97..51c12de5 100755 --- a/lib/reporters/console.js +++ b/lib/reporters/console.js @@ -136,6 +136,8 @@ internals.Reporter.prototype.end = function (notebook) { // Tests + const notes = notebook.tests.filter(internals.filterNotes); + const failures = notebook.tests.filter(internals.filterFailures); const skipped = notebook.tests.filter(internals.filterSkipped); @@ -340,6 +342,18 @@ internals.Reporter.prototype.end = function (notebook) { } } + if (notes.length) { + output += '\n\nTest notes:\n'; + notes.forEach((test) => { + + output += gray(test.relativeTitle) + '\n'; + test.notes.forEach((note) => { + + output += yellow(`\t* ${note}`); + }); + }); + } + output += '\n'; this.report(output); }; @@ -399,6 +413,12 @@ internals.colors = function (enabled) { }; +internals.filterNotes = function (test) { + + return test.notes && test.notes.length; +}; + + internals.filterFailures = function (test) { return !!test.err; diff --git a/lib/runner.js b/lib/runner.js index bf248f15..4f3cee0d 100755 --- a/lib/runner.js +++ b/lib/runner.js @@ -628,10 +628,18 @@ internals.protect = function (item, state, callback) { item.onCleanup = func; }; - const itemResult = item.fn.call(null, (err) => { + const done = (err) => { finish(err, 'done'); - }, onCleanup); + }; + + item.notes = []; + done.note = (note) => { + + item.notes.push(note); + }; + + const itemResult = item.fn.call(null, done, onCleanup); if (itemResult && itemResult.then instanceof Function) { diff --git a/test/reporters.js b/test/reporters.js index 0a235487..6186b174 100755 --- a/test/reporters.js +++ b/test/reporters.js @@ -681,6 +681,28 @@ describe('Reporter', () => { }); }); + it('generates a report with all notes displayed', (done) => { + + const script = Lab.script(); + script.experiment('test', () => { + + script.test('works', (finished) => { + + finished.note('This is a sweet feature'); + finished.note('Here is another note'); + finished(); + }); + }); + + Lab.report(script, { reporter: 'console', progress: 0, output: false }, (err, code, output) => { + + expect(err).not.to.exist(); + expect(output).to.contain('This is a sweet feature'); + expect(output).to.contain('Here is another note'); + done(); + }); + }); + it('generates a report without progress', (done) => { const script = Lab.script(); From 3f075c821f0063e6914ccfd476b82aca4e0ed073 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 23 May 2016 22:42:11 -0500 Subject: [PATCH 17/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35ca07ee..ebfa5e35 100755 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ lab.experiment('with only', () => { ``` The `test()` callback has a `note` function attached to it that can be used to -attach notes to the test case. These notes are included in the consoler reporter +attach notes to the test case. These notes are 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: From f4587d4a95e81c59916b7f4711691ee7f40e3ca9 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 24 May 2016 09:34:02 -0500 Subject: [PATCH 18/42] Correct note in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ebfa5e35..de0951d0 100755 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ lab.experiment('with only', () => { }); ``` -The `test()` callback has a `note` function attached to it that can be used to +The `test()` callback has a `note()` function attached to it that can be used to attach notes to the test case. These notes are 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: @@ -197,7 +197,7 @@ lab.test('attaches notes', (done) => { }); ``` -Multiple notes can be appended for the same test case by simply calling `note` +Multiple notes can be appended for the same test case by simply calling `note()` repeatedly. From b24daf4b506dfecfcedf32df939040f68737e71f Mon Sep 17 00:00:00 2001 From: "William P. Riley-Land" Date: Tue, 24 May 2016 12:06:46 -0500 Subject: [PATCH 19/42] Add --lint-fix option. (#591) --- README.md | 1 + lib/cli.js | 5 ++++ lib/lint.js | 39 ++++++++++++++++++++-------- lib/linter/index.js | 18 ++++++++++--- test/lint/eslint/fix/success.js | 14 ++++++++++ test/linters.js | 46 +++++++++++++++++++++++++++++++++ 6 files changed, 108 insertions(+), 15 deletions(-) create mode 100644 test/lint/eslint/fix/success.js diff --git a/README.md b/README.md index 14bc6951..95646fb7 100755 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ global manipulation. Our goal with **lab** is to keep the execution engine as si - `-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. - `-n`, `--linter` - specify linting program file path; default is `eslint`. +- `--lint-fix` - apply any fixes from the linter. Disabled by default. - `--lint-options` - specify options to pass to linting program. It must be a string that is JSON.parse(able). - `-o`, `--output` - file to write the report to, otherwise sent to stdout. - `-p`, `--parallel` - sets parallel execution as default test option. Defaults to serial execution. diff --git a/lib/cli.js b/lib/cli.js index 6c394697..4567f36d 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -220,6 +220,11 @@ internals.options = function () { description: 'linter path to use', default: 'eslint' }, + 'lint-fix': { + type: 'boolean', + description: 'apply any fixes from the linter.', + default: false + }, 'lint-options': { type: 'string', description: 'specify options to pass to linting program. It must be a string that is JSON.parse(able).' diff --git a/lib/lint.js b/lib/lint.js index 0902e696..f896d13c 100755 --- a/lib/lint.js +++ b/lib/lint.js @@ -3,6 +3,7 @@ // Load modules const ChildProcess = require('child_process'); +const Fs = require('fs'); // Declare internals @@ -15,9 +16,19 @@ const internals = { exports.lint = function (settings, callback) { const linterPath = (settings.linter && settings.linter !== 'eslint') ? settings.linter : internals.linter; - const child = ChildProcess.fork(linterPath, - settings['lint-options'] ? [settings['lint-options']] : [], - { cwd: settings.lintingPath }); + + let linterOptions; + + try { + linterOptions = JSON.parse(settings['lint-options'] || '{}'); + } + catch (err) { + throw new Error('lint-options could not be parsed'); + } + + linterOptions.fix = settings['lint-fix']; + + const child = ChildProcess.fork(linterPath, [JSON.stringify(linterOptions)], { cwd: settings.lintingPath }); child.once('message', (message) => { child.kill(); @@ -29,20 +40,26 @@ exports.lint = function (settings, callback) { let errors = 0; let warnings = 0; - lint.errors.forEach((err) => { + if (lint.errors) { + lint.errors.forEach((err) => { - if (err.severity === 'ERROR') { - errors++; - } - else { - warnings++; - } - }); + if (err.severity === 'ERROR') { + errors++; + } + else { + warnings++; + } + }); + } lint.totalErrors = errors; lint.totalWarnings = warnings; result.totalErrors += errors; result.totalWarnings += warnings; + + if (lint.fix) { + Fs.writeFileSync(lint.filename, lint.fix.output); + } }); result.total = result.totalErrors + result.totalWarnings; diff --git a/lib/linter/index.js b/lib/linter/index.js index bfd4fa26..18cd62a7 100755 --- a/lib/linter/index.js +++ b/lib/linter/index.js @@ -42,17 +42,27 @@ exports.lint = function () { return results.results.map((result) => { - return { - filename: result.filePath, - errors: result.messages.map((err) => { + const transformed = { + filename: result.filePath + }; + + if (result.hasOwnProperty('output')) { + transformed.fix = { + output: result.output + }; + } + else { + transformed.errors = result.messages.map((err) => { return { line: err.line, severity: err.severity === 1 ? 'WARNING' : 'ERROR', message: err.ruleId + ' - ' + err.message }; - }) + }); }; + + return transformed; }); }; diff --git a/test/lint/eslint/fix/success.js b/test/lint/eslint/fix/success.js new file mode 100644 index 00000000..f590a5f7 --- /dev/null +++ b/test/lint/eslint/fix/success.js @@ -0,0 +1,14 @@ +'use strict'; + +// Load modules + + +// Declare internals + +const internals = {}; + + +exports.method = function (value) { + + return value; +}; diff --git a/test/linters.js b/test/linters.js index 04a5bb95..89e7616b 100755 --- a/test/linters.js +++ b/test/linters.js @@ -6,6 +6,7 @@ const Path = require('path'); const _Lab = require('../test_runner'); const Code = require('code'); const Linters = require('../lib/lint'); +const Fs = require('fs'); // Test shortcuts @@ -151,6 +152,51 @@ describe('Linters - eslint', () => { done(); }); }); + + it('should fix lint rules when --lint-fix used', (done, onCleanup) => { + + const originalWriteFileSync = Fs.writeFileSync; + + onCleanup((next) => { + + Fs.writeFileSync = originalWriteFileSync; + next(); + }); + + Fs.writeFileSync = (path, output) => { + + expect(path).to.endWith('test/lint/eslint/fix/success.js'); + expect(output).to.endWith('\n\n return value;\n};\n'); + }; + + const path = Path.join(__dirname, 'lint', 'eslint', 'fix'); + Linters.lint({ lintingPath: path, linter: 'eslint', 'lint-fix': true }, (err, result) => { + + expect(err).to.not.exist(); + expect(result).to.include('lint'); + + const eslintResults = result.lint; + expect(eslintResults).to.have.length(1); + expect(eslintResults[0]).to.include({ + totalErrors: 0, + totalWarnings: 0 + }); + done(); + }); + }); + + it('should error on malformed lint-options', (done) => { + + const path = Path.join(__dirname, 'lint', 'eslint', 'fix'); + + const f = () => { + + Linters.lint({ lintingPath: path, linter: 'eslint', 'lint-options': '}' }, () => {}); + }; + + expect(f).to.throw('lint-options could not be parsed'); + done(); + }); }); describe('Linters - custom', () => { From c5ff7402f076851054cd6b1b0aa909760ad5e066 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 24 May 2016 12:08:09 -0500 Subject: [PATCH 20/42] Reorder requires --- test/linters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/linters.js b/test/linters.js index 89e7616b..c27a0e1b 100755 --- a/test/linters.js +++ b/test/linters.js @@ -2,11 +2,11 @@ // Load modules +const Fs = require('fs'); const Path = require('path'); const _Lab = require('../test_runner'); const Code = require('code'); const Linters = require('../lib/lint'); -const Fs = require('fs'); // Test shortcuts From 47754b51d7f1cc5d4d29630aadd9847164bb720f Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 24 May 2016 13:14:02 -0500 Subject: [PATCH 21/42] Cleanup lint-fix setting --- README.md | 2 +- lib/cli.js | 2 +- lib/lint.js | 20 +++++++++----------- lib/linter/index.js | 19 +++++++++---------- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 30633bd6..e2288cc8 100755 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ global manipulation. Our goal with **lab** is to keep the execution engine as si - `-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. - `-n`, `--linter` - specify linting program file path; default is `eslint`. -- `--lint-fix` - apply any fixes from the linter. Disabled by default. +- `--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). - `-o`, `--output` - file to write the report to, otherwise sent to stdout. - `-p`, `--parallel` - sets parallel execution as default test option. Defaults to serial execution. diff --git a/lib/cli.js b/lib/cli.js index 4567f36d..6077368c 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -337,7 +337,7 @@ internals.options = function () { const keys = ['coverage', 'coverage-path', 'coverage-exclude', 'colors', 'dry', 'debug', 'environment', 'flat', 'grep', 'globals', 'timeout', 'parallel', 'pattern', 'reporter', 'threshold', 'context-timeout', 'shuffle', 'sourcemaps', - 'lint', 'linter', 'transform', 'lint-options', 'lint-errors-threshold', 'lint-warnings-threshold', 'silent-skips']; + 'lint', 'linter', 'transform', 'lint-options', 'lint-fix', 'lint-errors-threshold', 'lint-warnings-threshold', 'silent-skips']; for (let i = 0; i < keys.length; ++i) { if (argv.hasOwnProperty(keys[i]) && argv[keys[i]] !== undefined) { options[keys[i]] = argv[keys[i]]; diff --git a/lib/lint.js b/lib/lint.js index f896d13c..85448ac1 100755 --- a/lib/lint.js +++ b/lib/lint.js @@ -40,17 +40,15 @@ exports.lint = function (settings, callback) { let errors = 0; let warnings = 0; - if (lint.errors) { - lint.errors.forEach((err) => { - - if (err.severity === 'ERROR') { - errors++; - } - else { - warnings++; - } - }); - } + lint.errors.forEach((err) => { + + if (err.severity === 'ERROR') { + errors++; + } + else { + warnings++; + } + }); lint.totalErrors = errors; lint.totalWarnings = warnings; diff --git a/lib/linter/index.js b/lib/linter/index.js index 18cd62a7..4df7a23f 100755 --- a/lib/linter/index.js +++ b/lib/linter/index.js @@ -51,16 +51,15 @@ exports.lint = function () { output: result.output }; } - else { - transformed.errors = result.messages.map((err) => { - - return { - line: err.line, - severity: err.severity === 1 ? 'WARNING' : 'ERROR', - message: err.ruleId + ' - ' + err.message - }; - }); - }; + + transformed.errors = result.messages.map((err) => { + + return { + line: err.line, + severity: err.severity === 1 ? 'WARNING' : 'ERROR', + message: err.ruleId + ' - ' + err.message + }; + }); return transformed; }); From c383daa688d7868b2ea89bddc46dc7f36e57ad55 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 24 May 2016 13:21:00 -0500 Subject: [PATCH 22/42] Cleanup lint-fix setting (#594) --- README.md | 2 +- lib/cli.js | 2 +- lib/lint.js | 20 +++++++++----------- lib/linter/index.js | 19 +++++++++---------- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 30633bd6..e2288cc8 100755 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ global manipulation. Our goal with **lab** is to keep the execution engine as si - `-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. - `-n`, `--linter` - specify linting program file path; default is `eslint`. -- `--lint-fix` - apply any fixes from the linter. Disabled by default. +- `--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). - `-o`, `--output` - file to write the report to, otherwise sent to stdout. - `-p`, `--parallel` - sets parallel execution as default test option. Defaults to serial execution. diff --git a/lib/cli.js b/lib/cli.js index 4567f36d..6077368c 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -337,7 +337,7 @@ internals.options = function () { const keys = ['coverage', 'coverage-path', 'coverage-exclude', 'colors', 'dry', 'debug', 'environment', 'flat', 'grep', 'globals', 'timeout', 'parallel', 'pattern', 'reporter', 'threshold', 'context-timeout', 'shuffle', 'sourcemaps', - 'lint', 'linter', 'transform', 'lint-options', 'lint-errors-threshold', 'lint-warnings-threshold', 'silent-skips']; + 'lint', 'linter', 'transform', 'lint-options', 'lint-fix', 'lint-errors-threshold', 'lint-warnings-threshold', 'silent-skips']; for (let i = 0; i < keys.length; ++i) { if (argv.hasOwnProperty(keys[i]) && argv[keys[i]] !== undefined) { options[keys[i]] = argv[keys[i]]; diff --git a/lib/lint.js b/lib/lint.js index f896d13c..85448ac1 100755 --- a/lib/lint.js +++ b/lib/lint.js @@ -40,17 +40,15 @@ exports.lint = function (settings, callback) { let errors = 0; let warnings = 0; - if (lint.errors) { - lint.errors.forEach((err) => { - - if (err.severity === 'ERROR') { - errors++; - } - else { - warnings++; - } - }); - } + lint.errors.forEach((err) => { + + if (err.severity === 'ERROR') { + errors++; + } + else { + warnings++; + } + }); lint.totalErrors = errors; lint.totalWarnings = warnings; diff --git a/lib/linter/index.js b/lib/linter/index.js index 18cd62a7..4df7a23f 100755 --- a/lib/linter/index.js +++ b/lib/linter/index.js @@ -51,16 +51,15 @@ exports.lint = function () { output: result.output }; } - else { - transformed.errors = result.messages.map((err) => { - - return { - line: err.line, - severity: err.severity === 1 ? 'WARNING' : 'ERROR', - message: err.ruleId + ' - ' + err.message - }; - }); - }; + + transformed.errors = result.messages.map((err) => { + + return { + line: err.line, + severity: err.severity === 1 ? 'WARNING' : 'ERROR', + message: err.ruleId + ' - ' + err.message + }; + }); return transformed; }); From 3c2a5ad4faa46cf932dd0722699258957f0930cc Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 24 May 2016 13:24:27 -0500 Subject: [PATCH 23/42] Update eslint to 2.10.x --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5601880..cbaa766e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "dependencies": { "bossy": "3.x.x", "diff": "2.x.x", - "eslint": "2.9.x", + "eslint": "2.10.x", "eslint-config-hapi": "9.x.x", "eslint-plugin-hapi": "4.x.x", "espree": "3.x.x", From efa156ec04418266ada05031c95d4650f448336a Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 24 May 2016 13:29:04 -0500 Subject: [PATCH 24/42] Update eslint to v2.10.x (#595) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5601880..cbaa766e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "dependencies": { "bossy": "3.x.x", "diff": "2.x.x", - "eslint": "2.9.x", + "eslint": "2.10.x", "eslint-config-hapi": "9.x.x", "eslint-plugin-hapi": "4.x.x", "espree": "3.x.x", From 7601a7fb3bdecc39dafb80e7eb692c0cd88debab Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 24 May 2016 13:30:38 -0500 Subject: [PATCH 25/42] version 10.7.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cbaa766e..fd54d838 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lab", "description": "Test utility", - "version": "10.6.1", + "version": "10.7.0", "repository": "git://github.com/hapijs/lab", "main": "lib/index.js", "keywords": [ From 572b9804e708a3ec7e8c7805a9510f28bc50baab Mon Sep 17 00:00:00 2001 From: Aaron Tribou Date: Wed, 25 May 2016 11:48:52 -0500 Subject: [PATCH 26/42] Adjust gray to comply with solarized dark theme (#596) --- lib/reporters/console.js | 2 +- test/reporters.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/reporters/console.js b/lib/reporters/console.js index 51c12de5..a2a946ba 100755 --- a/lib/reporters/console.js +++ b/lib/reporters/console.js @@ -391,7 +391,7 @@ internals.colors = function (enabled) { const codes = { 'black': 0, - 'gray': 90, + 'gray': 92, 'red': 31, 'green': 32, 'yellow': 33, diff --git a/test/reporters.js b/test/reporters.js index 6186b174..03e348ce 100755 --- a/test/reporters.js +++ b/test/reporters.js @@ -736,7 +736,7 @@ describe('Reporter', () => { Lab.report(script, { reporter: 'console', progress: 2, output: false }, (err, code, output) => { expect(err).not.to.exist(); - expect(output).to.match(/^test\n \u001b\[32m✔\u001b\[0m \u001b\[90m1\) works \(\d+ ms\)\u001b\[0m\n\n\n\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/); + expect(output).to.match(/^test\n \u001b\[32m✔\u001b\[0m \u001b\[92m1\) works \(\d+ ms\)\u001b\[0m\n\n\n\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/); done(); }); }); @@ -820,7 +820,7 @@ describe('Reporter', () => { Lab.report(script, { reporter: 'console', progress: 2, assert: Code, output: false }, (err, code, output) => { expect(err).not.to.exist(); - expect(output).to.match(/^test\n \u001b\[32m✔\u001b\[0m \u001b\[90m1\) works \(\d+ ms and \d+ assertions\)\u001b\[0m\n\n\n\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\nAssertions count\: \d+ \(verbosity\: \d+\.\d+\)\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/); + expect(output).to.match(/^test\n \u001b\[32m✔\u001b\[0m \u001b\[92m1\) works \(\d+ ms and \d+ assertions\)\u001b\[0m\n\n\n\u001b\[32m1 tests complete\u001b\[0m\nTest duration: \d+ ms\nAssertions count\: \d+ \(verbosity\: \d+\.\d+\)\n\u001b\[32mNo global variable leaks detected\u001b\[0m\n\n$/); done(); }); }); From ec6bcfb3c9b1e54bf3d30ed2ee9988b917ed0807 Mon Sep 17 00:00:00 2001 From: Martin Arista Date: Wed, 25 May 2016 18:54:42 -0500 Subject: [PATCH 27/42] Add space after failed test x (#597) --- lib/reporters/console.js | 2 +- test/reporters.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/reporters/console.js b/lib/reporters/console.js index a2a946ba..2be0c961 100755 --- a/lib/reporters/console.js +++ b/lib/reporters/console.js @@ -78,7 +78,7 @@ internals.Reporter.prototype.test = function (test) { const spacer = internals.spacer(test.path.length * 2); if (test.err) { - this.report(spacer + this.colors.red(asterisk + test.id + ') ' + test.relativeTitle) + '\n'); + this.report(spacer + this.colors.red(asterisk + ' ' + test.id + ') ' + test.relativeTitle) + '\n'); } else { const symbol = test.skipped || test.todo ? this.colors.magenta('-') : this.colors.green(check); diff --git a/test/reporters.js b/test/reporters.js index 03e348ce..30dbd0da 100755 --- a/test/reporters.js +++ b/test/reporters.js @@ -1073,7 +1073,7 @@ describe('Reporter', () => { expect(err).to.not.exist(); expect(code).to.equal(1); - expect(output).to.match(/test\n ✔ 1\) works \(\d+ ms\)\n ✖2\) fails\n \- 3\) skips \(\d+ ms\)\n/); + expect(output).to.match(/test\n ✔ 1\) works \(\d+ ms\)\n ✖ 2\) fails\n \- 3\) skips \(\d+ ms\)\n/); done(); }); }); From 619dc577d93d34464014b77e3be2ec2024322923 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Wed, 25 May 2016 18:58:10 -0500 Subject: [PATCH 28/42] version 10.7.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fd54d838..75d193c5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lab", "description": "Test utility", - "version": "10.7.0", + "version": "10.7.1", "repository": "git://github.com/hapijs/lab", "main": "lib/index.js", "keywords": [ From 613d73f6685c10dc5813d8937173400587279ea3 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Sat, 4 Jun 2016 09:32:07 -0500 Subject: [PATCH 29/42] Cleanup leak harmony checks --- lib/leaks.js | 32 +++++++------------------------- test/leaks.js | 2 +- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/lib/leaks.js b/lib/leaks.js index 85d323af..89b5f3e2 100755 --- a/lib/leaks.js +++ b/lib/leaks.js @@ -73,7 +73,13 @@ exports.detect = function (customGlobals) { TypeError: true, URIError: true, Boolean: true, - Intl: true + Intl: true, + Map: true, + Promise: true, + Set: true, + Symbol: true, + WeakMap: true, + WeakSet: true }; if (customGlobals) { @@ -82,34 +88,10 @@ exports.detect = function (customGlobals) { } } - if (global.Promise) { - whitelist.Promise = true; - } - if (global.Proxy) { whitelist.Proxy = true; } - if (global.Symbol) { - whitelist.Symbol = true; - } - - if (global.Map) { - whitelist.Map = true; - } - - if (global.WeakMap) { - whitelist.WeakMap = true; - } - - if (global.Set) { - whitelist.Set = true; - } - - if (global.WeakSet) { - whitelist.WeakSet = true; - } - if (global.Reflect) { whitelist.Reflect = true; } diff --git a/test/leaks.js b/test/leaks.js index a3419515..e7b98de4 100755 --- a/test/leaks.js +++ b/test/leaks.js @@ -10,7 +10,7 @@ const Lab = require('../'); // Declare internals const internals = { - harmonyGlobals: ['Promise', 'Proxy', 'Symbol', 'Map', 'WeakMap', 'Set', 'WeakSet', 'Reflect'] + harmonyGlobals: ['Proxy', 'Reflect'] }; From 64bb2b75d3ec90d71430d7a2bb189159a0a1941d Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Sat, 4 Jun 2016 09:34:41 -0500 Subject: [PATCH 30/42] Cleanup leak harmony checks (#599) --- lib/leaks.js | 32 +++++++------------------------- test/leaks.js | 2 +- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/lib/leaks.js b/lib/leaks.js index 85d323af..89b5f3e2 100755 --- a/lib/leaks.js +++ b/lib/leaks.js @@ -73,7 +73,13 @@ exports.detect = function (customGlobals) { TypeError: true, URIError: true, Boolean: true, - Intl: true + Intl: true, + Map: true, + Promise: true, + Set: true, + Symbol: true, + WeakMap: true, + WeakSet: true }; if (customGlobals) { @@ -82,34 +88,10 @@ exports.detect = function (customGlobals) { } } - if (global.Promise) { - whitelist.Promise = true; - } - if (global.Proxy) { whitelist.Proxy = true; } - if (global.Symbol) { - whitelist.Symbol = true; - } - - if (global.Map) { - whitelist.Map = true; - } - - if (global.WeakMap) { - whitelist.WeakMap = true; - } - - if (global.Set) { - whitelist.Set = true; - } - - if (global.WeakSet) { - whitelist.WeakSet = true; - } - if (global.Reflect) { whitelist.Reflect = true; } diff --git a/test/leaks.js b/test/leaks.js index a3419515..e7b98de4 100755 --- a/test/leaks.js +++ b/test/leaks.js @@ -10,7 +10,7 @@ const Lab = require('../'); // Declare internals const internals = { - harmonyGlobals: ['Promise', 'Proxy', 'Symbol', 'Map', 'WeakMap', 'Set', 'WeakSet', 'Reflect'] + harmonyGlobals: ['Proxy', 'Reflect'] }; From 4d228729a352a532be29c0a268c21a854610a53d Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 13 Jun 2016 20:31:38 -0500 Subject: [PATCH 31/42] Support .labrc.js for configuration (#601) * Support labrc * Support .labrc configuration file * Update docs * Move to .labrc.js file * Clarify labrc location --- README.md | 47 +++++++++++++++++++++++++++++++++++++++ lib/cli.js | 48 +++++++++++++++++++++++++--------------- lib/runner.js | 5 +++++ package.json | 1 + test/cli.js | 17 ++++++++++++++ test/cli_labrc/.labrc.js | 6 +++++ test/cli_labrc/index.js | 29 ++++++++++++++++++++++++ test/run_cli.js | 2 +- 8 files changed, 136 insertions(+), 19 deletions(-) create mode 100644 test/cli_labrc/.labrc.js create mode 100644 test/cli_labrc/index.js diff --git a/README.md b/README.md index e2288cc8..c9141978 100755 --- a/README.md +++ b/README.md @@ -367,6 +367,53 @@ if (typeof value === 'symbol') { ``` +## `.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: + +```js +module.exports = { + coverage: true, + threshold: 90, + lint: true +}; +``` + +### `.labrc.js` 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: + +```js +module.exports = { + coverage: true, + threshold: 100 +}; +``` + +If you need to reduce the coverage threshold for a single run, you can execute +**lab** as follows: + +```sh +lab -t 80 +``` + +### `.labrc.js` 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. + + ## Extending the linter **lab** uses a shareable [eslint](http://eslint.org/) config, and a plugin containing several **hapi** specific linting rules. If you want to extend the default linter you must: diff --git a/lib/cli.js b/lib/cli.js index 6077368c..e08434ca 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -5,18 +5,23 @@ const Fs = require('fs'); const Path = require('path'); const Bossy = require('bossy'); +const FindRc = require('find-rc'); const Hoek = require('hoek'); const Coverage = require('./coverage'); const Pkg = require('../package.json'); const Runner = require('./runner'); const Transform = require('./transform'); const Utils = require('./utils'); +// .labrc configuration will be required if it exists // Declare internals const internals = {}; +internals.rcPath = FindRc('lab'); +internals.rc = internals.rcPath ? require(internals.rcPath) : {}; + exports.run = function () { @@ -140,8 +145,8 @@ internals.options = function () { colors: { alias: 'C', type: 'boolean', - default: null, - description: 'enable color output (defaults to terminal capabilities)' + description: 'enable color output (defaults to terminal capabilities)', + default: null }, 'context-timeout': { alias: 'M', @@ -151,7 +156,8 @@ internals.options = function () { coverage: { alias: 'c', type: 'boolean', - description: 'enable code coverage analysis' + description: 'enable code coverage analysis', + default: null }, 'coverage-path': { type: 'string', @@ -165,24 +171,25 @@ internals.options = function () { debug: { alias: 'D', type: 'boolean', - default: false, - description: 'print the stack during a domain error event' + description: 'print the stack during a domain error event', + default: null }, dry: { alias: 'd', type: 'boolean', - description: 'skip all tests (dry run)' + description: 'skip all tests (dry run)', + default: null }, environment: { alias: 'e', type: 'string', - description: 'value to set NODE_ENV before tests', - default: 'test' + description: 'value to set NODE_ENV before tests' }, flat: { alias: 'f', type: 'boolean', - description: 'prevent recursive collection of tests within the provided path' + description: 'prevent recursive collection of tests within the provided path', + default: null }, globals: { alias: ['I', 'ignore'], @@ -207,12 +214,14 @@ internals.options = function () { leaks: { alias: 'l', type: 'boolean', - description: 'disable global variable leaks detection' + description: 'disable global variable leaks detection', + default: null }, lint: { alias: 'L', type: 'boolean', - description: 'enable linting' + description: 'enable linting', + default: null }, linter: { alias: 'n', @@ -223,7 +232,7 @@ internals.options = function () { 'lint-fix': { type: 'boolean', description: 'apply any fixes from the linter.', - default: false + default: null }, 'lint-options': { type: 'string', @@ -248,7 +257,8 @@ internals.options = function () { parallel: { alias: 'p', type: 'boolean', - description: 'parallel test execution within each experiment' + description: 'parallel test execution within each experiment', + default: null }, pattern: { alias: 'P', @@ -264,7 +274,8 @@ internals.options = function () { }, shuffle: { type: 'boolean', - description: 'shuffle script execution order' + description: 'shuffle script execution order', + default: null }, silence: { alias: 's', @@ -339,15 +350,13 @@ internals.options = function () { 'grep', 'globals', 'timeout', 'parallel', 'pattern', 'reporter', 'threshold', 'context-timeout', 'shuffle', 'sourcemaps', 'lint', 'linter', 'transform', 'lint-options', 'lint-fix', 'lint-errors-threshold', 'lint-warnings-threshold', 'silent-skips']; for (let i = 0; i < keys.length; ++i) { - if (argv.hasOwnProperty(keys[i]) && argv[keys[i]] !== undefined) { + if (argv.hasOwnProperty(keys[i]) && argv[keys[i]] !== undefined && argv[keys[i]] !== null) { options[keys[i]] = argv[keys[i]]; } } - options.environment = options.environment && options.environment.trim(); options.leaks = !argv.leaks; options.output = argv.output || process.stdout; - options.coverage = (options.coverage || options.threshold > 0 || options.reporter.indexOf('html') !== -1 || options.reporter.indexOf('lcov') !== -1 || options.reporter.indexOf('clover') !== -1); if (Array.isArray(options.reporter) && argv.output) { if (!Array.isArray(argv.output) || options.output.length !== options.reporter.length) { @@ -386,7 +395,10 @@ internals.options = function () { options.pattern = new RegExp(options.pattern + '\\.(js)$'); } - return options; + const merged = Utils.mergeOptions(internals.rc, options); + merged.coverage = (merged.coverage || merged.threshold > 0 || merged.reporter.indexOf('html') !== -1 || merged.reporter.indexOf('lcov') !== -1 || merged.reporter.indexOf('clover') !== -1); + + return merged; }; internals.mapTransform = function (transform) { diff --git a/lib/runner.js b/lib/runner.js index 4f3cee0d..d07887d5 100755 --- a/lib/runner.js +++ b/lib/runner.js @@ -49,9 +49,13 @@ internals.defaults = { parallel: false, progress: 1, reporter: 'console', + shuffle: false, // schedule: true, threshold: 0, + + lint: false, + 'lint-fix': false, 'lint-errors-threshold': 0, 'lint-warnings-threshold': 0 }; @@ -60,6 +64,7 @@ internals.defaults = { exports.report = function (scripts, options, callback) { const settings = Utils.mergeOptions(internals.defaults, options); + settings.environment = settings.environment.trim(); const reporter = Reporters.generate(settings); const executeScripts = function (next) { diff --git a/package.json b/package.json index 75d193c5..c6833280 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "eslint-config-hapi": "9.x.x", "eslint-plugin-hapi": "4.x.x", "espree": "3.x.x", + "find-rc": "3.0.x", "handlebars": "4.x.x", "hoek": "4.x.x", "items": "2.x.x", diff --git a/test/cli.js b/test/cli.js index 057e54b2..2c14fe5f 100755 --- a/test/cli.js +++ b/test/cli.js @@ -86,6 +86,23 @@ describe('CLI', () => { }); }); + it('runs a single test and uses .labrc when found', (done) => { + + RunCli([Path.join(__dirname, 'cli_labrc', 'index.js')], (error, result) => { + + if (error) { + done(error); + } + + expect(result.errorOutput).to.equal(''); + expect(result.code).to.equal(0); + expect(result.output).to.contain('1 tests complete'); + expect(result.output).to.contain('Coverage: 100'); + expect(result.output).to.contain('Linting results'); + done(); + }, Path.join(__dirname, 'cli_labrc')); + }); + it('exits with code 1 after function throws', (done) => { RunCli(['test/cli_throws/throws.js'], (error, result) => { diff --git a/test/cli_labrc/.labrc.js b/test/cli_labrc/.labrc.js new file mode 100644 index 00000000..049d5f39 --- /dev/null +++ b/test/cli_labrc/.labrc.js @@ -0,0 +1,6 @@ +module.exports = { + coverage: true, + environment: 'labrc', + threshold: 10, + lint: true +}; diff --git a/test/cli_labrc/index.js b/test/cli_labrc/index.js new file mode 100644 index 00000000..ef91acd6 --- /dev/null +++ b/test/cli_labrc/index.js @@ -0,0 +1,29 @@ +'use strict'; + +// Load modules + +const Code = require('code'); +const _Lab = require('../../test_runner'); + + +// Declare internals + +const internals = {}; + + +// Test shortcuts + +const lab = exports.lab = _Lab.script(); +const describe = lab.describe; +const it = lab.it; +const expect = Code.expect; + + +describe('Test .labrc.js', () => { + + it('sets environment from .labrc.js', (done) => { + + expect(process.env.NODE_ENV).to.equal('labrc'); + done(); + }); +}); diff --git a/test/run_cli.js b/test/run_cli.js index 9d77c337..5be0ea25 100644 --- a/test/run_cli.js +++ b/test/run_cli.js @@ -11,7 +11,7 @@ const internals = { module.exports = (args, callback, root) => { - const cli = ChildProcess.spawn('node', [].concat(internals.labPath, args), { 'cwd' : root ? root : '.' }); + const cli = ChildProcess.spawn('node', [].concat(internals.labPath, args), { cwd : root || '.' }); let output = ''; let errorOutput = ''; let combinedOutput = ''; From be3fd2d15443383bda6fe026c15d631880f2641a Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 13 Jun 2016 20:33:19 -0500 Subject: [PATCH 32/42] version 10.8.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c6833280..9cf80103 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lab", "description": "Test utility", - "version": "10.7.1", + "version": "10.8.0", "repository": "git://github.com/hapijs/lab", "main": "lib/index.js", "keywords": [ From d924a41fdda1638482491a24a38b44edcf16d3ac Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 13 Jun 2016 20:47:36 -0500 Subject: [PATCH 33/42] Reduce size of npm install --- .npmignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..d7302d84 --- /dev/null +++ b/.npmignore @@ -0,0 +1,6 @@ +* +!lib/** +!bin/lab +!.npmignore +!.eslintignore +!README.md From 1a2cd97bc9bd19dedb43c3a4ca3d5b3f5d89d66b Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 13 Jun 2016 20:59:49 -0500 Subject: [PATCH 34/42] Display a warning for failed patterns --- lib/cli.js | 37 ++++++++++++++++++++----------------- test/cli.js | 15 +++++++++++++++ 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index e08434ca..136faafc 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -102,33 +102,36 @@ internals.traverse = function (paths, options) { testFiles = testFiles.concat(traverse(path)); }); + if (options.pattern && !testFiles.length) { + options.output.write('The pattern provided (-P or --pattern) didn\'t match any files.'); + process.exit(0); + } + testFiles = testFiles.map((path) => { return Path.resolve(path); }); const scripts = []; - if (testFiles.length) { - testFiles.forEach((file) => { + testFiles.forEach((file) => { - global._labScriptRun = false; - file = Path.resolve(file); - const pkg = require(file); - if (pkg.lab && - pkg.lab._root) { + global._labScriptRun = false; + file = Path.resolve(file); + const pkg = require(file); + if (pkg.lab && + pkg.lab._root) { - scripts.push(pkg.lab); + scripts.push(pkg.lab); - if (pkg.lab._cli) { - Utils.applyOptions(options, pkg.lab._cli); - } + if (pkg.lab._cli) { + Utils.applyOptions(options, pkg.lab._cli); } - else if (global._labScriptRun) { - options.output.write('The file: ' + file + ' includes a lab script that is not exported via exports.lab'); - return process.exit(1); - } - }); - } + } + else if (global._labScriptRun) { + options.output.write('The file: ' + file + ' includes a lab script that is not exported via exports.lab'); + return process.exit(1); + } + }); return scripts; }; diff --git a/test/cli.js b/test/cli.js index 2c14fe5f..01f2897d 100755 --- a/test/cli.js +++ b/test/cli.js @@ -810,6 +810,21 @@ describe('CLI', () => { }); }); + it('reports a warning when no files matching the pattern are found', (done) => { + + RunCli(['test/cli_pattern', '-m', '2000', '-a', 'code', '-P', 'nofiles'], (error, result) => { + + if (error) { + done(error); + } + + expect(result.errorOutput).to.equal(''); + expect(result.code).to.equal(0); + expect(result.output).to.contain('The pattern provided (-P or --pattern) didn\'t match any files.'); + done(); + }); + }); + it('only loads files matching pattern when pattern at beginning of name (-P)', (done) => { RunCli(['test/cli_pattern', '-m', '2000', '-a', 'code', '-P', 'file'], (error, result) => { From cc849b5b00a62e17869efc27a80b18aa3ac8d1c4 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 13 Jun 2016 21:06:48 -0500 Subject: [PATCH 35/42] Display a warning for failed patterns (#603) --- lib/cli.js | 37 ++++++++++++++++++++----------------- test/cli.js | 15 +++++++++++++++ 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index e08434ca..136faafc 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -102,33 +102,36 @@ internals.traverse = function (paths, options) { testFiles = testFiles.concat(traverse(path)); }); + if (options.pattern && !testFiles.length) { + options.output.write('The pattern provided (-P or --pattern) didn\'t match any files.'); + process.exit(0); + } + testFiles = testFiles.map((path) => { return Path.resolve(path); }); const scripts = []; - if (testFiles.length) { - testFiles.forEach((file) => { + testFiles.forEach((file) => { - global._labScriptRun = false; - file = Path.resolve(file); - const pkg = require(file); - if (pkg.lab && - pkg.lab._root) { + global._labScriptRun = false; + file = Path.resolve(file); + const pkg = require(file); + if (pkg.lab && + pkg.lab._root) { - scripts.push(pkg.lab); + scripts.push(pkg.lab); - if (pkg.lab._cli) { - Utils.applyOptions(options, pkg.lab._cli); - } + if (pkg.lab._cli) { + Utils.applyOptions(options, pkg.lab._cli); } - else if (global._labScriptRun) { - options.output.write('The file: ' + file + ' includes a lab script that is not exported via exports.lab'); - return process.exit(1); - } - }); - } + } + else if (global._labScriptRun) { + options.output.write('The file: ' + file + ' includes a lab script that is not exported via exports.lab'); + return process.exit(1); + } + }); return scripts; }; diff --git a/test/cli.js b/test/cli.js index 2c14fe5f..01f2897d 100755 --- a/test/cli.js +++ b/test/cli.js @@ -810,6 +810,21 @@ describe('CLI', () => { }); }); + it('reports a warning when no files matching the pattern are found', (done) => { + + RunCli(['test/cli_pattern', '-m', '2000', '-a', 'code', '-P', 'nofiles'], (error, result) => { + + if (error) { + done(error); + } + + expect(result.errorOutput).to.equal(''); + expect(result.code).to.equal(0); + expect(result.output).to.contain('The pattern provided (-P or --pattern) didn\'t match any files.'); + done(); + }); + }); + it('only loads files matching pattern when pattern at beginning of name (-P)', (done) => { RunCli(['test/cli_pattern', '-m', '2000', '-a', 'code', '-P', 'file'], (error, result) => { From ba1b01556f7a33ed0af15706cd65d9c54e2570e0 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 13 Jun 2016 21:21:52 -0500 Subject: [PATCH 36/42] version 10.8.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9cf80103..841fbebf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lab", "description": "Test utility", - "version": "10.8.0", + "version": "10.8.1", "repository": "git://github.com/hapijs/lab", "main": "lib/index.js", "keywords": [ From 2f40e253f96eb8b04994946fba3cb0a1701dc860 Mon Sep 17 00:00:00 2001 From: Nicolas Morel Date: Wed, 15 Jun 2016 01:56:42 +0200 Subject: [PATCH 37/42] Fix NODE_ENV not being set (fixes #606) (#608) --- lib/cli.js | 1 + test/run_cli.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cli.js b/lib/cli.js index 136faafc..feece650 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -400,6 +400,7 @@ internals.options = function () { const merged = Utils.mergeOptions(internals.rc, options); merged.coverage = (merged.coverage || merged.threshold > 0 || merged.reporter.indexOf('html') !== -1 || merged.reporter.indexOf('lcov') !== -1 || merged.reporter.indexOf('clover') !== -1); + merged.environment = merged.environment || 'test'; return merged; }; diff --git a/test/run_cli.js b/test/run_cli.js index 5be0ea25..b432d096 100644 --- a/test/run_cli.js +++ b/test/run_cli.js @@ -11,7 +11,9 @@ const internals = { module.exports = (args, callback, root) => { - const cli = ChildProcess.spawn('node', [].concat(internals.labPath, args), { cwd : root || '.' }); + const childEnv = Object.assign({}, process.env); + delete childEnv.NODE_ENV; + const cli = ChildProcess.spawn('node', [].concat(internals.labPath, args), { env: childEnv, cwd : root || '.' }); let output = ''; let errorOutput = ''; let combinedOutput = ''; From 461f2bf78fbfe51473734e0f49cbea4c0a8be13c Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Tue, 14 Jun 2016 18:58:22 -0500 Subject: [PATCH 38/42] version 10.8.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 841fbebf..78eb314a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lab", "description": "Test utility", - "version": "10.8.1", + "version": "10.8.2", "repository": "git://github.com/hapijs/lab", "main": "lib/index.js", "keywords": [ From 1fafc20b6d801479fe1d90eb7e4e04aeecff200f Mon Sep 17 00:00:00 2001 From: Lloyd Benson Date: Fri, 24 Jun 2016 12:11:50 -0500 Subject: [PATCH 39/42] closes #610 (#611) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 78eb314a..485ed2c8 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "dependencies": { "bossy": "3.x.x", "diff": "2.x.x", - "eslint": "2.10.x", + "eslint": "2.13.x", "eslint-config-hapi": "9.x.x", "eslint-plugin-hapi": "4.x.x", "espree": "3.x.x", From bbbc2b0c02021dd125a5899a7c5b8e4257291e63 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Wed, 29 Jun 2016 11:14:58 -0500 Subject: [PATCH 40/42] labrc.js can override all cli options (#613) * Support rc overrides for all cli options * test for more labrc overrides --- lib/cli.js | 148 ++++++++++++++++++++++++++------------- test/cli.js | 2 + test/cli_labrc/.labrc.js | 4 +- 3 files changed, 103 insertions(+), 51 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index feece650..51fc225b 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -143,7 +143,8 @@ internals.options = function () { assert: { alias: 'a', type: 'string', - description: 'specify an assertion library module path to require and make available under Lab.assertions' + description: 'specify an assertion library module path to require and make available under Lab.assertions', + default: null }, colors: { alias: 'C', @@ -154,7 +155,8 @@ internals.options = function () { 'context-timeout': { alias: 'M', type: 'number', - description: 'timeout for before, after, beforeEach, afterEach in milliseconds' + description: 'timeout for before, after, beforeEach, afterEach in milliseconds', + default: null }, coverage: { alias: 'c', @@ -164,12 +166,14 @@ internals.options = function () { }, 'coverage-path': { type: 'string', - description: 'set code coverage path' + description: 'set code coverage path', + default: null }, 'coverage-exclude': { type: 'string', description: 'set code coverage excludes', - multiple: true + multiple: true, + default: null }, debug: { alias: 'D', @@ -186,7 +190,8 @@ internals.options = function () { environment: { alias: 'e', type: 'string', - description: 'value to set NODE_ENV before tests' + description: 'value to set NODE_ENV before tests', + default: null }, flat: { alias: 'f', @@ -197,22 +202,26 @@ internals.options = function () { globals: { alias: ['I', 'ignore'], type: 'string', - description: 'ignore a list of globals for the leak detection (comma separated)' + description: 'ignore a list of globals for the leak detection (comma separated)', + default: null }, grep: { alias: 'g', type: 'string', - description: 'only run tests matching the given pattern which is internally compiled to a RegExp' + description: 'only run tests matching the given pattern which is internally compiled to a RegExp', + default: null }, help: { alias: 'h', type: 'boolean', - description: 'display usage options' + description: 'display usage options', + default: null }, id: { alias: 'i', type: 'range', - description: 'test identifier' + description: 'test identifier', + default: null }, leaks: { alias: 'l', @@ -230,7 +239,7 @@ internals.options = function () { alias: 'n', type: 'string', description: 'linter path to use', - default: 'eslint' + default: null }, 'lint-fix': { type: 'boolean', @@ -239,23 +248,25 @@ internals.options = function () { }, 'lint-options': { type: 'string', - description: 'specify options to pass to linting program. It must be a string that is JSON.parse(able).' + description: 'specify options to pass to linting program. It must be a string that is JSON.parse(able).', + default: null }, 'lint-errors-threshold': { type: 'number', description: 'linter errors threshold in absolute value', - default: 0 + default: null }, 'lint-warnings-threshold': { type: 'number', description: 'linter warnings threshold in absolute value', - default: 0 + default: null }, output: { alias: 'o', type: 'string', description: 'file path to write test results', - multiple: true + multiple: true, + default: null }, parallel: { alias: 'p', @@ -266,14 +277,15 @@ internals.options = function () { pattern: { alias: 'P', type: 'string', - description: 'file pattern to use for locating tests' + description: 'file pattern to use for locating tests', + default: null }, reporter: { alias: 'r', type: 'string', description: 'reporter type [console, html, json, tap, lcov, clover, junit]', - default: 'console', - multiple: true + multiple: true, + default: null }, shuffle: { type: 'boolean', @@ -283,45 +295,77 @@ internals.options = function () { silence: { alias: 's', type: 'boolean', - description: 'silence test output' + description: 'silence test output', + default: null }, 'silent-skips': { alias: 'k', type: 'boolean', - description: 'don’t output skipped tests' + description: 'don’t output skipped tests', + default: null }, sourcemaps: { alias: ['S', 'sourcemaps'], type: 'boolean', - description: 'enable support for sourcemaps' + description: 'enable support for sourcemaps', + default: null }, threshold: { alias: 't', type: 'number', - description: 'code coverage threshold percentage' + description: 'code coverage threshold percentage', + default: null }, timeout: { alias: 'm', type: 'number', - description: 'timeout for each test in milliseconds' + description: 'timeout for each test in milliseconds', + default: null }, transform: { alias: ['T', 'transform'], type: 'string', - description: 'javascript file that exports an array of objects ie. [ { ext: ".js", transform: function (content, filename) { ... } } ]' + description: 'javascript file that exports an array of objects ie. [ { ext: ".js", transform: function (content, filename) { ... } } ]', + default: null }, verbose: { alias: 'v', type: 'boolean', - description: 'verbose test output' + description: 'verbose test output', + default: null }, version: { alias: 'V', type: 'boolean', - description: 'version information' + description: 'version information', + default: null } }; + const defaults = { + verbose: false, + paths: ['test'], + coverage: false, + debug: true, + dry: false, + environment: 'test', + flat: false, + leaks: true, + lint: false, + linter: 'eslint', + 'lint-fix': false, + 'lint-errors-threshold': 0, + 'lint-warnings-threshold': 0, + parallel: false, + reporter: 'console', + shuffle: false, + silence: false, + 'silent-skips': false, + sourcemaps: false, + timeout: 2000, + verbose: false + }; + const argv = Bossy.parse(definition); if (argv instanceof Error) { @@ -340,49 +384,55 @@ internals.options = function () { process.exit(0); } - const options = { - paths: argv._ ? [].concat(argv._) : ['test'] - }; + const options = Utils.mergeOptions(defaults, internals.rc); + options.paths = argv._ ? [].concat(argv._) : options.paths; - if (argv.assert) { - options.assert = require(argv.assert); - require('./').assertions = options.assert; - } - - const keys = ['coverage', 'coverage-path', 'coverage-exclude', 'colors', 'dry', 'debug', 'environment', 'flat', - 'grep', 'globals', 'timeout', 'parallel', 'pattern', 'reporter', 'threshold', 'context-timeout', 'shuffle', 'sourcemaps', - 'lint', 'linter', 'transform', 'lint-options', 'lint-fix', 'lint-errors-threshold', 'lint-warnings-threshold', 'silent-skips']; + const keys = ['assert', 'colors', 'context-timeout', 'coverage', 'coverage-exclude', + 'coverage-path', 'debug', 'dry', 'environment', 'flat', 'globals', 'grep', + 'lint', 'lint-errors-threshold', 'lint-fix', 'lint-options', 'lint-warnings-threshold', + 'linter', 'output', 'parallel', 'pattern', 'reporter', 'shuffle', 'silence', + 'silent-skips', 'sourcemaps', 'threshold', 'timeout', 'transform', 'verbose']; for (let i = 0; i < keys.length; ++i) { if (argv.hasOwnProperty(keys[i]) && argv[keys[i]] !== undefined && argv[keys[i]] !== null) { options[keys[i]] = argv[keys[i]]; } } - options.leaks = !argv.leaks; - options.output = argv.output || process.stdout; + if (typeof argv.leaks === 'boolean') { + options.leaks = !argv.leaks; + } + + if (argv.id) { + options.ids = argv.id; + } - if (Array.isArray(options.reporter) && argv.output) { - if (!Array.isArray(argv.output) || options.output.length !== options.reporter.length) { + if (Array.isArray(options.reporter) && options.output) { + if (!Array.isArray(options.output) || options.output.length !== options.reporter.length) { console.error(Bossy.usage(definition, 'lab [options] [path]')); process.exit(1); } } + if (!options.output) { + options.output = process.stdout; + } + + if (options.assert) { + options.assert = require(options.assert); + require('./').assertions = options.assert; + } + if (options.globals) { options.globals = options.globals.trim().split(','); } - if (argv.silence) { + if (options.silence) { options.progress = 0; } - else if (argv.verbose) { + else if (options.verbose) { options.progress = 2; } - if (argv.id) { - options.ids = argv.id; - } - options.pattern = options.pattern ? '.*' + options.pattern + '.*?' : ''; if (options.transform) { const transform = require(Path.resolve(options.transform)); @@ -398,11 +448,9 @@ internals.options = function () { options.pattern = new RegExp(options.pattern + '\\.(js)$'); } - const merged = Utils.mergeOptions(internals.rc, options); - merged.coverage = (merged.coverage || merged.threshold > 0 || merged.reporter.indexOf('html') !== -1 || merged.reporter.indexOf('lcov') !== -1 || merged.reporter.indexOf('clover') !== -1); - merged.environment = merged.environment || 'test'; + options.coverage = (options.coverage || options.threshold > 0 || options.reporter.indexOf('html') !== -1 || options.reporter.indexOf('lcov') !== -1 || options.reporter.indexOf('clover') !== -1); - return merged; + return options; }; internals.mapTransform = function (transform) { diff --git a/test/cli.js b/test/cli.js index 01f2897d..7d5a3f24 100755 --- a/test/cli.js +++ b/test/cli.js @@ -97,8 +97,10 @@ describe('CLI', () => { expect(result.errorOutput).to.equal(''); expect(result.code).to.equal(0); expect(result.output).to.contain('1 tests complete'); + expect(result.output).to.contain('sets environment from .labrc.js'); expect(result.output).to.contain('Coverage: 100'); expect(result.output).to.contain('Linting results'); + expect(result.output).to.not.contain('No global variable leaks detected'); done(); }, Path.join(__dirname, 'cli_labrc')); }); diff --git a/test/cli_labrc/.labrc.js b/test/cli_labrc/.labrc.js index 049d5f39..afc0cb28 100644 --- a/test/cli_labrc/.labrc.js +++ b/test/cli_labrc/.labrc.js @@ -2,5 +2,7 @@ module.exports = { coverage: true, environment: 'labrc', threshold: 10, - lint: true + lint: true, + leaks: false, + verbose: true }; From 9ed01db9827b6850650bd298ecdd6f27ae41df00 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 11 Jul 2016 13:45:56 +0100 Subject: [PATCH 41/42] Update eslint to v3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 485ed2c8..263b4175 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "dependencies": { "bossy": "3.x.x", "diff": "2.x.x", - "eslint": "2.13.x", + "eslint": "3.0.x", "eslint-config-hapi": "9.x.x", "eslint-plugin-hapi": "4.x.x", "espree": "3.x.x", From bce47429dfda991897717265053406c078cbf3fe Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 11 Jul 2016 13:56:37 +0100 Subject: [PATCH 42/42] version 10.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 263b4175..7b4f27d3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lab", "description": "Test utility", - "version": "10.8.2", + "version": "10.9.0", "repository": "git://github.com/hapijs/lab", "main": "lib/index.js", "keywords": [