Skip to content
Permalink
Browse files
feat(cucumber): cucumber adapter reports pending scenarios
affects: @integration/cucumber
  • Loading branch information
jan-molak committed Jul 29, 2018
1 parent 5717a4d commit 0d4f7984db3a8290465b006dd70a3fb71bf04405
@@ -0,0 +1,10 @@
Feature: Serenity/JS recognises pending scenarios

Scenario: A scenario with steps marked as pending

Given a step that's marked as pending

Scenario: A scenario with steps that have not been implemented yet

Given a step that hasn't been implemented yet

@@ -11,12 +11,8 @@ export = function() {
done(new Error(`Something's wrong`));
});

this.Given(/^.*step (?:.*) explicitly pending$/, function(done: Callback) {
done(void 0, 'pending');
});

this.Given(/^.*step (?:.*) explicitly skipped/, function(done: Callback) {
done(void 0, 'skipped');
this.Given(/^.*step (?:.*) marked as (pending|skipped)/, function(result: string, done: Callback) {
done(void 0, result);
});

this.Given(/^.*step (?:.*) receives a table:$/, function(data: TableDefinition, done) {
@@ -9,12 +9,8 @@ export = function() {
return Promise.reject(new Error(`Something's wrong`));
});

this.Given(/^.*step (?:.*) explicitly pending$/, function() {
return Promise.resolve('pending');
});

this.Given(/^.*step (?:.*) explicitly skipped/, function() {
return Promise.resolve('skipped');
this.Given(/^.*step (?:.*) marked as (pending|skipped)/, function(result: string) {
return Promise.resolve(result);
});

this.Given(/^.*step (?:.*) receives a table:$/, function(data: TableDefinition, done) {
@@ -9,12 +9,8 @@ export = function() {
throw new Error(`Something's wrong`);
});

this.Given(/^.*step (?:.*) explicitly pending$/, function() {
return 'pending';
});

this.Given(/^.*step (?:.*) explicitly skipped/, function() {
return 'skipped';
this.Given(/^.*step (?:.*) marked as (pending|skipped)/, function(result: string) {
return result;
});

this.Given(/^.*step (?:.*) receives a table:$/, function(data: TableDefinition) {
@@ -1,5 +1,5 @@
import { expect, ifExitCodeIsOtherThan, logOutput } from '@integration/testing-tools';
import { SceneBackgroundDetected, SceneDescriptionDetected, SceneStarts } from '@serenity-js/core/lib/events';
import { SceneDescriptionDetected, SceneStarts } from '@serenity-js/core/lib/events';
import { Description, Name } from '@serenity-js/core/lib/model';

import 'mocha';
@@ -0,0 +1,78 @@
import { expect, ifExitCodeIsOtherThan, logOutput } from '@integration/testing-tools';
import {
ActivityFinished,
ActivityStarts,
SceneFinished,
SceneStarts,
SceneTagged,
TestRunnerDetected,
} from '@serenity-js/core/lib/events';
import { FeatureTag, ImplementationPending, Name } from '@serenity-js/core/lib/model';

import 'mocha';
import { given } from 'mocha-testdata';

import { cucumber, Pick } from '../src';

describe('@serenity-js/cucumber', function() {

this.timeout(5000);

given([
'synchronous',
'promise',
'callback',
]).
it(`recognises a pending scenario where some steps are marked as 'pending'`, (stepInterface: string) =>
cucumber(
'--require', 'features/support/configure_serenity.ts',
'--require', `features/step_definitions/${ stepInterface }.steps.ts`,
'--require', 'node_modules/@serenity-js/cucumber/register.js',
'features/pending_scenarios.feature',
'--name', 'A scenario with steps marked as pending',
).
then(ifExitCodeIsOtherThan(0, logOutput)).
then(res => {
expect(res.exitCode).to.equal(0);

expect(res.events).to.have.lengthOf(6);

Pick.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario with steps marked as pending')))
.next(TestRunnerDetected, event => expect(event.value).to.equal(new Name('Cucumber')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises pending scenarios')))
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(`Given a step that's marked as pending`)))
.next(ActivityFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
;
}));

given([
'synchronous',
'promise',
'callback',
]).
it(`recognises a pending scenario where some steps are marked as 'pending'`, (stepInterface: string) =>
cucumber(
'--require', 'features/support/configure_serenity.ts',
'--require', `features/step_definitions/${ stepInterface }.steps.ts`,
'--require', 'node_modules/@serenity-js/cucumber/register.js',
'features/pending_scenarios.feature',
'--name', 'A scenario with steps that have not been implemented yet',
).
then(ifExitCodeIsOtherThan(0, logOutput)).
then(res => {
expect(res.exitCode).to.equal(0);

expect(res.events).to.have.lengthOf(6);

Pick.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario with steps that have not been implemented yet')))
.next(TestRunnerDetected, event => expect(event.value).to.equal(new Name('Cucumber')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises pending scenarios')))
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(`Given a step that hasn't been implemented yet`)))
.next(ActivityFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
;
}));
});

0 comments on commit 0d4f798

Please sign in to comment.