Skip to content
Permalink
Browse files
feat(cucumber): support for Cucumber.js 3.x
affects: @serenity-js/core, @serenity-js/cucumber, @integration/cucumber-1-runner,
@integration/cucumber-2-runner, @integration/cucumber-3-runner, @integration/cucumber,
@integration/testing-tools

ISSUES CLOSED: #28
  • Loading branch information
jan-molak committed Aug 29, 2018
1 parent 33656f5 commit ecfe34fdb5690e67928c093135ae92a155c9c2e8
Showing with 950 additions and 176 deletions.
  1. +1 −1 integration/cucumber-1-runner/README.md
  2. +3 −3 integration/cucumber-1-runner/package.json
  3. +2 −1 integration/cucumber-1-runner/tsconfig-lint.json
  4. +1 −1 integration/cucumber-2-runner/README.md
  5. +0 −2 integration/cucumber-2-runner/features/support/configure_serenity.ts
  6. +3 −3 integration/cucumber-2-runner/package.json
  7. +2 −1 integration/cucumber-2-runner/tsconfig-lint.json
  8. +7 −0 integration/cucumber-3-runner/.gitignore
  9. +8 −0 integration/cucumber-3-runner/README.md
  10. +12 −0 integration/cucumber-3-runner/features/step_definitions/ambiguous.steps.ts
  11. +30 −0 integration/cucumber-3-runner/features/step_definitions/callback.steps.ts
  12. +29 −0 integration/cucumber-3-runner/features/step_definitions/promise.steps.ts
  13. +23 −0 integration/cucumber-3-runner/features/step_definitions/synchronous.steps.ts
  14. +8 −0 integration/cucumber-3-runner/features/support/after_hook.ts
  15. +8 −0 integration/cucumber-3-runner/features/support/before_hook.ts
  16. +13 −0 integration/cucumber-3-runner/features/support/configure_serenity.ts
  17. +8 −0 integration/cucumber-3-runner/features/support/wip_hook.ts
  18. +44 −0 integration/cucumber-3-runner/package.json
  19. +19 −0 integration/cucumber-3-runner/src/index.ts
  20. +11 −0 integration/cucumber-3-runner/tsconfig-lint.json
  21. +20 −0 integration/cucumber-3-runner/tsconfig.json
  22. +0 −1 integration/cucumber/features/passing_scenario.feature
  23. +2 −5 integration/cucumber/package.json
  24. +17 −6 integration/cucumber/spec/ambiguous_steps.spec.ts
  25. +15 −4 integration/cucumber/spec/capabilities.spec.ts
  26. +15 −4 integration/cucumber/spec/data_table.spec.ts
  27. +15 −4 integration/cucumber/spec/descriptions.spec.ts
  28. +15 −4 integration/cucumber/spec/doc_string.spec.ts
  29. +15 −4 integration/cucumber/spec/failing_scenario.spec.ts
  30. +15 −4 integration/cucumber/spec/passing_scenario.spec.ts
  31. +86 −11 integration/cucumber/spec/pending_scenarios.spec.ts
  32. +15 −4 integration/cucumber/spec/scenario_outlines.spec.ts
  33. +19 −5 integration/cucumber/spec/tags.spec.ts
  34. +15 −4 integration/cucumber/spec/themes.spec.ts
  35. +15 −4 integration/cucumber/spec/timed_out_scenario.spec.ts
  36. +2 −4 integration/cucumber/src/CucumberRunner.ts
  37. +4 −4 integration/cucumber/src/CucumberRunnerBuilder.ts
  38. +19 −0 integration/testing-tools/bin/parallel-mocha.js
  39. +3 −0 integration/testing-tools/package.json
  40. +30 −30 package-lock.json
  41. +1 −0 package.json
  42. +45 −0 packages/core/spec/io/ErrorSerialiser.spec.ts
  43. +7 −0 packages/core/src/errors/UnknownError.ts
  44. +1 −0 packages/core/src/errors/index.ts
  45. +9 −0 packages/core/src/io/ErrorSerialiser.ts
  46. +43 −0 packages/cucumber/spec/gherkin/feature-files/Cache.spec.ts
  47. +2 −2 packages/cucumber/spec/gherkin/feature-files/FeatureFileLoader.spec.ts
  48. +6 −4 packages/cucumber/spec/gherkin/feature-files/FeatureFileMapper.spec.ts
  49. +10 −0 packages/cucumber/src/adapters/CucumberFormatterOptions.ts
  50. +4 −1 packages/cucumber/src/adapters/Dependencies.ts
  51. +22 −40 packages/cucumber/src/adapters/cucumber-0.ts
  52. +2 −2 packages/cucumber/src/adapters/cucumber-2.ts
  53. +130 −3 packages/cucumber/src/adapters/cucumber-3.ts
  54. +15 −4 packages/cucumber/src/adapters/index.ts
  55. +7 −0 packages/cucumber/src/errors/AmbiguousStepDefinitionError.ts
  56. +1 −0 packages/cucumber/src/errors/index.ts
  57. +37 −0 packages/cucumber/src/gherkin/feature-files/Cache.ts
  58. +2 −1 packages/cucumber/src/gherkin/feature-files/FeatureFileLoader.ts
  59. +4 −3 packages/cucumber/src/gherkin/feature-files/FeatureFileMap.ts
  60. +6 −1 packages/cucumber/src/gherkin/feature-files/FeatureFileMapper.ts
  61. +7 −0 packages/cucumber/src/gherkin/feature-files/errors/ItemNotFoundError.ts
  62. +7 −0 packages/cucumber/src/gherkin/feature-files/errors/UnableToRetrieveFeatureFileMap.ts
  63. +3 −1 packages/cucumber/src/gherkin/feature-files/errors/index.ts
  64. +1 −0 packages/cucumber/src/gherkin/feature-files/index.ts
  65. +1 −0 packages/cucumber/src/gherkin/model/Scenario.ts
  66. +6 −0 packages/cucumber/src/index.ts
  67. +2 −0 packages/cucumber/src/register.ts
@@ -4,4 +4,4 @@ This is an internal test module that embeds Cucumber 1.3
so that it can be executed against the integration tests in [`integration/cucumber`](../cucumber)

## Notes
- [Cucumber.js step definitions](https://github.com/cucumber/cucumber-js/blob/1.x/docs/support_files/step_definitions.md)
- [Cucumber.js step definitions](https://github.com/cucumber/cucumber-js/blob/v1.3.3/docs/support_files/step_definitions.md)
@@ -35,10 +35,10 @@
"dependencies": {
"@integration/testing-tools": "*",
"@serenity-js/core": "*",
"@serenity-js/cucumber": "*"
"@serenity-js/cucumber": "*",
"cucumber": "1.3.3"
},
"devDependencies": {
"@types/cucumber": "1.3.3",
"cucumber": "1.3.3"
"@types/cucumber": "1.3.3"
}
}
@@ -2,7 +2,8 @@
"extends": "./tsconfig",
"include": [
"src/**/*.ts",
"spec/**/*.ts"
"spec/**/*.ts",
"features/**/*.ts"
],
"exclude": [
"node_modules"
@@ -4,4 +4,4 @@ This is an internal test module that embeds Cucumber 2.3
so that it can be executed against the integration tests in [`integration/cucumber`](../cucumber)

## Notes
- [Cucumber.js step definitions](https://github.com/cucumber/cucumber-js/blob/2.x/docs/support_files/step_definitions.md)
- [Cucumber.js step definitions](https://github.com/cucumber/cucumber-js/blob/v2.3.1/docs/support_files/step_definitions.md)
@@ -6,8 +6,6 @@ import { defineSupportCode } from 'cucumber';
defineSupportCode(({ setDefaultTimeout }) => {
setDefaultTimeout(5000);

console.log('>>> configure_serenity :: loading serenity from', require.resolve('@serenity-js/core'));

serenity.stageManager.register(
new ChildProcessReporter(),
new DebugReporter(),
@@ -35,10 +35,10 @@
"dependencies": {
"@integration/testing-tools": "*",
"@serenity-js/core": "*",
"@serenity-js/cucumber": "*"
"@serenity-js/cucumber": "*",
"cucumber": "2.3.1"
},
"devDependencies": {
"@types/cucumber": "2.1.0",
"cucumber": "2.3.1"
"@types/cucumber": "2.1.0"
}
}
@@ -2,7 +2,8 @@
"extends": "./tsconfig",
"include": [
"src/**/*.ts",
"spec/**/*.ts"
"spec/**/*.ts",
"features/**/*.ts"
],
"exclude": [
"node_modules"
@@ -0,0 +1,7 @@
# Node
node_modules
*.log

# Build artifacts
.nyc_output
lib
@@ -0,0 +1,8 @@
# Cucumber 2.x runner

This is an internal test module that embeds Cucumber 2.3
so that it can be executed against the integration tests in [`integration/cucumber`](../cucumber)

## Notes
- [Cucumber.js step definitions](https://github.com/cucumber/cucumber-js/blob/v3.2.1/docs/support_files/step_definitions.md)
- [Sample event protocol events](https://github.com/cucumber/cucumber-js/blob/v4.2.1/src/formatter/event_protocol_formatter.js)
@@ -0,0 +1,12 @@
import { defineSupportCode } from 'cucumber';

defineSupportCode(({ Given }) => {

Given(/^.*step (?:.*) passes$/, function() {
return void 0;
});

Given(/^.*step (?:.*) passes$/, function() {
return void 0;
});
});
@@ -0,0 +1,30 @@
import { defineSupportCode, TableDefinition } from 'cucumber';

type Callback = (error?: Error, pending?: string) => void;

defineSupportCode(({ Given }) => {

Given(/^.*step (?:.*) passes$/, function(done: Callback) {
done();
});

Given(/^.*step (?:.*) fails$/, function(done: Callback) {
done(new Error(`Something's wrong`));
});

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

Given(/^.*step (?:.*) receives a table:$/, function(data: TableDefinition, done) {
done();
});

Given(/^.*step (?:.*) receives a doc string:$/, function(docstring: string, done) {
done();
});

Given(/^.*step that times out$/, { timeout: 100 }, function(done: Callback) {
setTimeout(done, 1000);
});
});
@@ -0,0 +1,29 @@
import { defineSupportCode, TableDefinition } from 'cucumber';

defineSupportCode(({ Given }) => {
Given(/^.*step (?:.*) passes$/, function() {
return Promise.resolve();
});

Given(/^.*step (?:.*) fails$/, function() {
return Promise.reject(new Error(`Something's wrong`));
});

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

Given(/^.*step (?:.*) receives a table:$/, function(data: TableDefinition) {
return Promise.resolve();
});

Given(/^.*step (?:.*) receives a doc string:$/, function(docstring: string) {
return Promise.resolve();
});

Given(/^.*step that times out$/, { timeout: 100 }, function() {
return new Promise((resolve, reject) => {
setTimeout(resolve, 1000);
});
});
});
@@ -0,0 +1,23 @@
import { defineSupportCode, TableDefinition } from 'cucumber';

defineSupportCode(({ Given }) => {
Given(/^.*step (?:.*) passes$/, function() {
return void 0;
});

Given(/^.*step (?:.*) fails$/, function() {
throw new Error(`Something's wrong`);
});

Given(/^.*step (?:.*) marked as pending/, function() {
return 'pending';
});

Given(/^.*step (?:.*) receives a table:$/, function(data: TableDefinition) {
return void 0;
});

Given(/^.*step (?:.*) receives a doc string:$/, function(docstring: string) {
return void 0;
});
});
@@ -0,0 +1,8 @@
import { defineSupportCode } from 'cucumber';

defineSupportCode(({ After }) => {

After(function() {
// no-op
});
});
@@ -0,0 +1,8 @@
import { defineSupportCode } from 'cucumber';

defineSupportCode(({ Before }) => {

Before(function() {
// no-op
});
});
@@ -0,0 +1,13 @@
import { ChildProcessReporter } from '@integration/testing-tools';
import { serenity } from '@serenity-js/core';
import { DebugReporter } from '@serenity-js/core/lib/stage';
import { defineSupportCode } from 'cucumber';

defineSupportCode(({ setDefaultTimeout }) => {
setDefaultTimeout(5000);

serenity.stageManager.register(
new ChildProcessReporter(),
new DebugReporter(),
);
});
@@ -0,0 +1,8 @@
import { defineSupportCode } from 'cucumber';

defineSupportCode(({ Before }) => {

Before({ tags: '@wip' }, function() {
return 'pending';
});
});
@@ -0,0 +1,44 @@
{
"name": "@integration/cucumber-3-runner",
"version": "0.0.0",
"description": "Cucumber JS 3.x test runner",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"author": {
"name" : "Jan Molak",
"email" : "jan.molak@smartcodeltd.co.uk",
"url" : "https://janmolak.com"
},
"homepage": "http://serenity-js.org",
"license": "Apache-2.0",
"private": true,
"config": {
"access": "private"
},
"scripts": {
"clean": "rimraf lib",
"lint": "tslint --project tsconfig-lint.json --config ../../tslint.json --format stylish",
"test": "exit 0",
"compile": "tsc --project tsconfig.json"
},
"repository": {
"type": "git",
"url": "https://github.com/jan-molak/serenity-js.git"
},
"bugs": {
"url": "https://github.com/jan-molak/serenity-js/issues"
},
"engines": {
"node": ">= 6.9.x",
"npm": ">= 3"
},
"dependencies": {
"@integration/testing-tools": "*",
"@serenity-js/core": "*",
"@serenity-js/cucumber": "*",
"cucumber": "3.2.1"
},
"devDependencies": {
"@types/cucumber": "3.2.2"
}
}
@@ -0,0 +1,19 @@
import { spawner, SpawnResult } from '@integration/testing-tools';
import * as path from 'path';

const cucumberExecutable = path.resolve(
require.resolve('cucumber/package.json'),
'..',
'bin',
'cucumber.js',
);

const cucumberSpawner = spawner(
cucumberExecutable,
{ cwd: path.resolve(__dirname, '..') },
);

export = (...params: string[]): Promise<SpawnResult> => cucumberSpawner(
'--compiler', 'ts:ts-node/register',
...params,
);
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig",
"include": [
"src/**/*.ts",
"spec/**/*.ts",
"features/**/*.ts"
],
"exclude": [
"node_modules"
]
}
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": [ "es5", "es6" ],
"module": "commonjs",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"declaration": true,
"outDir": "./lib"
},

"include": [
"src"
],

"exclude": [
"node_modules"
]
}
@@ -3,4 +3,3 @@ Feature: Serenity/JS recognises a passing scenario
Scenario: A passing scenario

Given a step that passes

@@ -16,7 +16,7 @@
"scripts": {
"clean": "rimraf lib",
"lint": "tslint --project tsconfig-lint.json --config ../../tslint.json --format stylish",
"test": "mocha --opts ../../mocha.opts 'spec/**/*.spec.*'",
"test": "parallel-mocha --opts ../../mocha.opts 'spec/**/*.spec.*'",
"test:parallel": "mocha-parallel-tests --opts ../../mocha.opts 'spec/**/*.spec.*'"
},
"repository": {
@@ -34,11 +34,8 @@
"@integration/testing-tools": "*",
"@integration/cucumber-1-runner": "*",
"@integration/cucumber-2-runner": "*",
"@integration/cucumber-3-runner": "*",
"@serenity-js/core": "*",
"@serenity-js/cucumber": "*"
},
"devDependencies": {
"@types/cucumber": "1.3.3",
"cucumber": "1.3.3"
}
}

0 comments on commit ecfe34f

Please sign in to comment.