Skip to content

Commit

Permalink
Add support for cucumber 4
Browse files Browse the repository at this point in the history
  • Loading branch information
darrinholst committed Jan 28, 2018
1 parent 05d3ea0 commit 1ce5f44
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@ For Maintainers

1. bump version
1. `npm publish`
1. tag release (`git tag v1.0.2 && git push origin master --tags`)
1. build github release (`npm i -g release && release`)
1. tag release (`git tag vx.x.x && git push origin master --tags`)
1. build github release (`npx release`)

1 change: 1 addition & 0 deletions lib/resultsCapturer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ switch (cucumberVersion) {
break;

case 3:
case 4:
module.exports = eventListeners;
break;

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "protractor-cucumber-framework",
"version": "4.1.1",
"version": "4.2.0",
"description": "Protractor framework for Cucumber.js",
"main": "index.js",
"engines": {
Expand All @@ -11,7 +11,7 @@
"start": "node test/testapp/server",
"lint": "eslint . --fix",
"pretest": "npm run lint && multidep test/multidep.js",
"test": "mocha -c -s 10000 -t 20000 test/**/*.spec.js"
"test": "mocha -c -s 10000 -t 30000 test/**/*.spec.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -80,7 +80,8 @@
"cucumberConf": {
"version1": "1.3.3",
"version2": "2.3.1",
"version3": "3.0.6"
"version3": "3.0.6",
"version4": "4.0.0"
},
"prettier": {
"printWidth": 80,
Expand Down
11 changes: 11 additions & 0 deletions test/cucumber/conf/cucumber4Conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let env = require('./environment.js');

exports.config = Object.assign({}, env, {
cucumberOpts: {
require: '../stepDefinitions/**/cucumber4Steps.js',
tags: '',
format: 'summary',
strict: true,
'format-options': '{"colorsEnabled": false}'
}
});
6 changes: 6 additions & 0 deletions test/cucumber/features/cucumber4.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Running Cucumber 4 with Protractor

@cucumber4
Scenario: Using Cucumber 4
Given I go on "index.html"
Then the title should equal "My AngularJS App"
21 changes: 21 additions & 0 deletions test/cucumber/stepDefinitions/cucumber4Steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const path = require('path');
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
const expect = chai.expect;
const {Given, Then} = require(path.join(
__dirname,
'..',
'..',
'..',
'lib',
'cucumberLoader'
)).load();

Given('I go on {string}', function(url) {
return browser.get(url);
});

Then(/the title should equal "([^"]*)"$/, function(text) {
return expect(browser.getTitle()).to.eventually.equal(text);
});
16 changes: 16 additions & 0 deletions test/cucumber4.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let util = require('./test_util');

describe('cucumber version 4', function() {
it('runs successful features', function() {
return util
.runOne(
'test/cucumber/conf/cucumber4Conf.js --cucumberOpts.tags @cucumber4'
)
.cucumberVersion4()
.expectExitCode(0)
.expectOutput('1 scenario (1 passed)')
.expectOutput('2 steps (2 passed)')
.expectErrors([])
.run();
});
});
2 changes: 1 addition & 1 deletion test/multidep.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ let conf = require(path.join(__dirname, '..', 'package.json')).cucumberConf;
module.exports = {
path: 'test/multidep_modules',
versions: {
cucumber: [conf.version1, conf.version2, conf.version3]
cucumber: [conf.version1, conf.version2, conf.version3, conf.version4]
}
};
4 changes: 2 additions & 2 deletions test/output-files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('output files', () => {
return util
.runOne(cmd)
.expectExitCode(0)
.after(() => expect(findLogFiles()).to.have.length(4)) //note: this will increase for every feature file we have
.after(() => expect(findLogFiles()).to.have.length(5)) //note: this will increase for every feature file we have
.run();
});

Expand Down Expand Up @@ -65,7 +65,7 @@ describe('output files', () => {
.runOne(cmd)
.cucumberVersion2()
.expectExitCode(0)
.after(() => expect(findLogFiles()).to.have.length(4))
.after(() => expect(findLogFiles()).to.have.length(5))
.run();
});

Expand Down
5 changes: 5 additions & 0 deletions test/test_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ let CommandlineTest = function(args) {
return self;
};

this.cucumberVersion4 = function() {
self.cucumberVesion_ = cucumberConf.version4;
return self;
};

this.expectExitCode = function(exitCode) {
self.expectedExitCode_ = exitCode;
return self;
Expand Down

0 comments on commit 1ce5f44

Please sign in to comment.