diff --git a/lib/reporter.js b/lib/reporter.js index 02c156c..79d1508 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -84,7 +84,8 @@ class CucumberReporter { case Cucumber.Status.PENDING: case Cucumber.Status.SKIPPED: case Cucumber.Status.AMBIGUOUS: - e = 'pending' + e = 'skipped' + break } let error = {} let stepTitle = step.getName() || step.getKeyword() || 'Undefined Step' diff --git a/test/fixtures/steps-status-step-definitions.js b/test/fixtures/steps-status-step-definitions.js new file mode 100644 index 0000000..00cfcdd --- /dev/null +++ b/test/fixtures/steps-status-step-definitions.js @@ -0,0 +1,13 @@ +var assert = require('assert') + +module.exports = function () { + this.Given(/Test will fail/, (url) => { + return assert.ok(false, 'expected failure') + }) + + this.Given('Pending test', () => 'pending') + + this.Then(/this step will be skipped/, (selector) => { + throw new Error('unexpected error') + }) +} diff --git a/test/fixtures/steps-status.conf.js b/test/fixtures/steps-status.conf.js new file mode 100644 index 0000000..1d64845 --- /dev/null +++ b/test/fixtures/steps-status.conf.js @@ -0,0 +1,11 @@ +export default { + sync: false, + capabilities: { + browserName: 'chrome' + }, + + cucumberOpts: { + timeout: 5000, + require: [__dirname + '/steps-status-step-definitions.js'] + } +} diff --git a/test/fixtures/steps-status.feature b/test/fixtures/steps-status.feature new file mode 100644 index 0000000..5d7c1a9 --- /dev/null +++ b/test/fixtures/steps-status.feature @@ -0,0 +1,9 @@ +Feature: Steps status + + Scenario: Failing test + Given Test will fail + And this step will be skipped + Then this step will be skipped + + Scenario: Pending + Given Pending test diff --git a/test/steps.spec.js b/test/steps.spec.js new file mode 100644 index 0000000..f75d5d3 --- /dev/null +++ b/test/steps.spec.js @@ -0,0 +1,44 @@ +import { CucumberAdapter } from '../lib/adapter' +import CucumberReporter from '../lib/reporter' +import config from './fixtures/steps-status.conf' + +const specs = ['./test/fixtures/steps-status.feature'] + +const WebdriverIO = class {} + +describe('steps', () => { + it('should report different status for steps', async () => { + const messages = [] + const send = CucumberReporter.prototype.send + CucumberReporter.prototype.send = message => messages.push(message) + global.browser = new WebdriverIO() + global.browser.options = config + const adapter = new CucumberAdapter(0, config, specs, {}) + + ;(await adapter.run()).should.be.equal(1) + + messages.map(msg => msg.event).should.be.deepEqual([ + 'suite:start', + + // failed + 'suite:start', + 'test:start', + 'test:fail', + 'test:start', + 'test:skipped', + 'test:start', + 'test:skipped', + 'suite:end', + + // pending + 'suite:start', + 'test:start', + 'test:skipped', + 'suite:end', + + 'suite:end' + ]) + + CucumberReporter.prototype.send = send + }) +})