From 51b8bb61cf35bcc76d81f546e58d47612ea4cfeb Mon Sep 17 00:00:00 2001 From: JaeHyeonKim19 Date: Fri, 16 Aug 2019 15:43:32 +0900 Subject: [PATCH 1/2] make forbid-only as default on CI(#3030) --- lib/cli/run.js | 1 + package-scripts.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/cli/run.js b/lib/cli/run.js index dc94c101a4..227014fdf2 100644 --- a/lib/cli/run.js +++ b/lib/cli/run.js @@ -108,6 +108,7 @@ exports.builder = yargs => requiresArg: true }, 'forbid-only': { + default: process.env.CI, description: 'Fail if exclusive test(s) encountered', group: GROUPS.RULES }, diff --git a/package-scripts.js b/package-scripts.js index 7febdc016f..9845728a9d 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -12,8 +12,8 @@ const path = require('path'); function test(testName, mochaParams) { const coverageCommand = `nyc --no-clean --report-dir coverage/reports/${testName}`; const mochaCommand = `node ${path.join('bin', 'mocha')}`; // Include 'node' and path.join for Windows compatibility - if (process.env.CI && !/^only-/.test(testName)) { - mochaParams += ' --forbid-only'; + if (process.env.CI && /^only-/.test(testName)) { + mochaParams += ' --no-forbid-only'; } return `${ process.env.COVERAGE ? coverageCommand : '' From fcdb971e4a0c609a37fc5554dffc82614118f72d Mon Sep 17 00:00:00 2001 From: JaeHyeonKim19 Date: Sat, 26 Oct 2019 17:04:09 +0900 Subject: [PATCH 2/2] Fix failed test cases(#3030) Test cases broken because of making forbid-only as default in CI.. --- test/integration/only.spec.js | 75 ++++++++++++++------------ test/integration/options/delay.spec.js | 5 +- test/integration/regression.spec.js | 10 +++- 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/test/integration/only.spec.js b/test/integration/only.spec.js index 5ea37ae947..1c845c01da 100644 --- a/test/integration/only.spec.js +++ b/test/integration/only.spec.js @@ -6,52 +6,61 @@ var assert = require('assert'); describe('.only()', function() { describe('bdd', function() { it('should run only tests that marked as `only`', function(done) { - run('options/only/bdd.fixture.js', ['--ui', 'bdd'], function(err, res) { - if (err) { - done(err); - return; + run( + 'options/only/bdd.fixture.js', + ['--ui', 'bdd', '--no-forbid-only'], + function(err, res) { + if (err) { + done(err); + return; + } + assert.strictEqual(res.stats.pending, 0); + assert.strictEqual(res.stats.passes, 11); + assert.strictEqual(res.stats.failures, 0); + assert.strictEqual(res.code, 0); + done(); } - assert.strictEqual(res.stats.pending, 0); - assert.strictEqual(res.stats.passes, 11); - assert.strictEqual(res.stats.failures, 0); - assert.strictEqual(res.code, 0); - done(); - }); + ); }); }); describe('tdd', function() { it('should run only tests that marked as `only`', function(done) { - run('options/only/tdd.fixture.js', ['--ui', 'tdd'], function(err, res) { - if (err) { - done(err); - return; + run( + 'options/only/tdd.fixture.js', + ['--ui', 'tdd', '--no-forbid-only'], + function(err, res) { + if (err) { + done(err); + return; + } + assert.strictEqual(res.stats.pending, 0); + assert.strictEqual(res.stats.passes, 8); + assert.strictEqual(res.stats.failures, 0); + assert.strictEqual(res.code, 0); + done(); } - assert.strictEqual(res.stats.pending, 0); - assert.strictEqual(res.stats.passes, 8); - assert.strictEqual(res.stats.failures, 0); - assert.strictEqual(res.code, 0); - done(); - }); + ); }); }); describe('qunit', function() { it('should run only tests that marked as `only`', function(done) { - run('options/only/qunit.fixture.js', ['--ui', 'qunit'], function( - err, - res - ) { - if (err) { - done(err); - return; + run( + 'options/only/qunit.fixture.js', + ['--ui', 'qunit', '--no-forbid-only'], + function(err, res) { + if (err) { + done(err); + return; + } + assert.strictEqual(res.stats.pending, 0); + assert.strictEqual(res.stats.passes, 5); + assert.strictEqual(res.stats.failures, 0); + assert.strictEqual(res.code, 0); + done(); } - assert.strictEqual(res.stats.pending, 0); - assert.strictEqual(res.stats.passes, 5); - assert.strictEqual(res.stats.failures, 0); - assert.strictEqual(res.code, 0); - done(); - }); + ); }); }); }); diff --git a/test/integration/options/delay.spec.js b/test/integration/options/delay.spec.js index ae9ff70f29..e5b526281a 100644 --- a/test/integration/options/delay.spec.js +++ b/test/integration/options/delay.spec.js @@ -25,7 +25,10 @@ describe('--delay', function() { it('should execute exclusive tests only', function(done) { var fixture = path.join('options', 'delay-only'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args.concat(['--no-forbid-only']), function( + err, + res + ) { if (err) { return done(err); } diff --git a/test/integration/regression.spec.js b/test/integration/regression.spec.js index ae4f4fba59..77f028011f 100644 --- a/test/integration/regression.spec.js +++ b/test/integration/regression.spec.js @@ -71,7 +71,10 @@ describe('regressions', function() { }); it('issue-2406: should run nested describe.only suites', function(done) { - runJSON('regression/issue-2406.fixture.js', [], function(err, res) { + runJSON('regression/issue-2406.fixture.js', ['--no-forbid-only'], function( + err, + res + ) { if (err) { done(err); return; @@ -84,7 +87,10 @@ describe('regressions', function() { }); it('issue-2417: should not recurse infinitely with .only suites nested within each other', function(done) { - runJSON('regression/issue-2417.fixture.js', [], function(err, res) { + runJSON('regression/issue-2417.fixture.js', ['--no-forbid-only'], function( + err, + res + ) { if (err) { done(err); return;