From 23e302a8dc35d03ba82916bd6591822a28d499d1 Mon Sep 17 00:00:00 2001 From: vancouverwill Date: Sun, 17 Mar 2019 16:57:31 +0000 Subject: [PATCH] Don't report filtered tests as pending --- lib/run-status.js | 2 +- test/fixture/report/timeoutwithmatch/a.js | 15 +++++++++++++++ .../report/timeoutwithmatch/package.json | 1 + test/helper/report.js | 5 +++-- test/reporters/verbose.js | 1 + test/reporters/verbose.timeoutwithmatch.log | 17 +++++++++++++++++ 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 test/fixture/report/timeoutwithmatch/a.js create mode 100644 test/fixture/report/timeoutwithmatch/package.json create mode 100644 test/reporters/verbose.timeoutwithmatch.log diff --git a/lib/run-status.js b/lib/run-status.js index b2b5998b9..336f9c3f6 100644 --- a/lib/run-status.js +++ b/lib/run-status.js @@ -59,7 +59,6 @@ class RunStatus extends Emittery { case 'declared-test': stats.declaredTests++; fileStats.declaredTests++; - this.addPendingTest(event); break; case 'hook-failed': stats.failedHooks++; @@ -84,6 +83,7 @@ class RunStatus extends Emittery { } else { stats.remainingTests++; fileStats.remainingTests++; + this.addPendingTest(event); } break; diff --git a/test/fixture/report/timeoutwithmatch/a.js b/test/fixture/report/timeoutwithmatch/a.js new file mode 100644 index 000000000..53d2d5c31 --- /dev/null +++ b/test/fixture/report/timeoutwithmatch/a.js @@ -0,0 +1,15 @@ +import test from '../../../..'; + +test('passes needle', t => t.pass()); + +test.cb('slow needle', t => { + setTimeout(t.end, 15000); +}); +test.cb('slow two', t => { + setTimeout(t.end, 15000); +}); +test.cb('slow three needle', t => { + setTimeout(t.end, 15000); +}); + +test('passes two', t => t.pass()); diff --git a/test/fixture/report/timeoutwithmatch/package.json b/test/fixture/report/timeoutwithmatch/package.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/test/fixture/report/timeoutwithmatch/package.json @@ -0,0 +1 @@ +{} diff --git a/test/helper/report.js b/test/helper/report.js index a32ff6747..2fe3362ab 100644 --- a/test/helper/report.js +++ b/test/helper/report.js @@ -81,7 +81,7 @@ exports.sanitizers = { version: str => replaceString(str, `v${pkg.version}`, 'v1.0.0-beta.5.1') }; -const run = (type, reporter) => { +const run = (type, reporter, match = []) => { const projectDir = path.join(__dirname, '../fixture/report', type.toLowerCase()); const options = { @@ -96,7 +96,7 @@ const run = (type, reporter) => { require: [], cacheEnabled: true, compileEnhancements: true, - match: [], + match, babelConfig: {testOptions: {}}, resolveTestsFrom: projectDir, projectDir, @@ -144,6 +144,7 @@ exports.failFast2 = reporter => run('failFast2', reporter); exports.only = reporter => run('only', reporter); exports.timeoutInSingleFile = reporter => run('timeoutInSingleFile', reporter); exports.timeoutInMultipleFiles = reporter => run('timeoutInMultipleFiles', reporter); +exports.timeoutWithMatch = reporter => run('timeoutWithMatch', reporter, ['*needle*']); exports.watch = reporter => run('watch', reporter); exports.typescript = reporter => run('typescript', reporter); exports.edgeCases = reporter => run('edge-cases', reporter); diff --git a/test/reporters/verbose.js b/test/reporters/verbose.js index ffc66bcad..2d7ee73ec 100644 --- a/test/reporters/verbose.js +++ b/test/reporters/verbose.js @@ -44,5 +44,6 @@ test('verbose reporter - timeout', t => { t.test('single file run', run('timeoutInSingleFile')); t.test('multiple files run', run('timeoutInMultipleFiles')); + t.test('single file with only certain tests matched run', run('timeoutWithMatch')); t.end(); }); diff --git a/test/reporters/verbose.timeoutwithmatch.log b/test/reporters/verbose.timeoutwithmatch.log new file mode 100644 index 000000000..38edccf4e --- /dev/null +++ b/test/reporters/verbose.timeoutwithmatch.log @@ -0,0 +1,17 @@ + +---tty-stream-chunk-separator + ✔ passes needle +---tty-stream-chunk-separator +  + ✖ Timed out while running tests + + 2 tests were pending in ~/test/fixture/report/timeoutwithmatch/a.js + + ◌ slow needle + ◌ slow three needle + +---tty-stream-chunk-separator + + 1 test passed + +---tty-stream-chunk-separator