diff --git a/lib/plugin/allure.js b/lib/plugin/allure.js index 844f43529..798e3be0f 100644 --- a/lib/plugin/allure.js +++ b/lib/plugin/allure.js @@ -108,7 +108,7 @@ module.exports = (config) => { } }; - plugin.createStep = (name, stepFunc = () => {}) => { + plugin.createStep = (name, stepFunc = () => { }) => { let result; let status = 'passed'; reporter.startStep(name); @@ -119,8 +119,8 @@ module.exports = (config) => { throw error; } finally { if (!!result - && (typeof result === 'object' || typeof result === 'function') - && typeof result.then === 'function' + && (typeof result === 'object' || typeof result === 'function') + && typeof result.then === 'function' ) { result.then(() => reporter.endStep('passed'), () => reporter.endStep('broken')); } else { @@ -234,6 +234,18 @@ module.exports = (config) => { reporter.endCase('passed'); }); + event.dispatcher.on(event.test.skipped, (test) => { + let loaded = true; + if (test.opts.skipInfo.isFastSkipped) { + loaded = false; + reporter.startSuite(test.parent.fullTitle()); + } + reporter.pendingCase(test.title, null, test.opts.skipInfo); + if (!loaded) { + reporter.endSuite(); + } + }); + event.dispatcher.on(event.step.started, (step) => { if (isHookSteps === false) { startMetaStep(step.metaStep); diff --git a/lib/reporter/cli.js b/lib/reporter/cli.js index 74cd177f5..586557dab 100644 --- a/lib/reporter/cli.js +++ b/lib/reporter/cli.js @@ -11,7 +11,7 @@ class Cli extends Base { constructor(runner, opts) { super(runner); let level = 0; - this.failedTests = []; + this.loadedTests = []; opts = opts.reporterOptions || opts; if (opts.steps) level = 1; if (opts.debug) level = 2; @@ -43,7 +43,7 @@ class Cli extends Base { runner.on('fail', (test, err) => { if (test.ctx.currentTest) { - this.failedTests.push(test.ctx.currentTest.id); + this.loadedTests.push(test.ctx.currentTest.id); } if (showSteps && test.steps) { return output.scenario.failed(test); @@ -53,6 +53,7 @@ class Cli extends Base { }); runner.on('pending', (test) => { + this.loadedTests.push(test.id); cursor.CR(); output.test.skipped(test); }); @@ -97,8 +98,13 @@ class Cli extends Base { let skippedCount = 0; const grep = runner._grep; for (const test of suite.tests) { - if (!test.state && !this.failedTests.includes(test.id)) { + if (!test.state && !this.loadedTests.includes(test.id)) { if (matchTest(grep, test.title)) { + if (!test.opts.skipInfo) { + test.opts.skipInfo = {}; + } + test.opts.skipInfo.message = 'Skipped due to failure in \'before\' hook'; + test.opts.skipInfo.isFastSkipped = true; event.emit(event.test.skipped, test); test.state = 'skipped'; output.test.skipped(test);