Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
with
950 additions
and 176 deletions.
- +1 −1 integration/cucumber-1-runner/README.md
- +3 −3 integration/cucumber-1-runner/package.json
- +2 −1 integration/cucumber-1-runner/tsconfig-lint.json
- +1 −1 integration/cucumber-2-runner/README.md
- +0 −2 integration/cucumber-2-runner/features/support/configure_serenity.ts
- +3 −3 integration/cucumber-2-runner/package.json
- +2 −1 integration/cucumber-2-runner/tsconfig-lint.json
- +7 −0 integration/cucumber-3-runner/.gitignore
- +8 −0 integration/cucumber-3-runner/README.md
- +12 −0 integration/cucumber-3-runner/features/step_definitions/ambiguous.steps.ts
- +30 −0 integration/cucumber-3-runner/features/step_definitions/callback.steps.ts
- +29 −0 integration/cucumber-3-runner/features/step_definitions/promise.steps.ts
- +23 −0 integration/cucumber-3-runner/features/step_definitions/synchronous.steps.ts
- +8 −0 integration/cucumber-3-runner/features/support/after_hook.ts
- +8 −0 integration/cucumber-3-runner/features/support/before_hook.ts
- +13 −0 integration/cucumber-3-runner/features/support/configure_serenity.ts
- +8 −0 integration/cucumber-3-runner/features/support/wip_hook.ts
- +44 −0 integration/cucumber-3-runner/package.json
- +19 −0 integration/cucumber-3-runner/src/index.ts
- +11 −0 integration/cucumber-3-runner/tsconfig-lint.json
- +20 −0 integration/cucumber-3-runner/tsconfig.json
- +0 −1 integration/cucumber/features/passing_scenario.feature
- +2 −5 integration/cucumber/package.json
- +17 −6 integration/cucumber/spec/ambiguous_steps.spec.ts
- +15 −4 integration/cucumber/spec/capabilities.spec.ts
- +15 −4 integration/cucumber/spec/data_table.spec.ts
- +15 −4 integration/cucumber/spec/descriptions.spec.ts
- +15 −4 integration/cucumber/spec/doc_string.spec.ts
- +15 −4 integration/cucumber/spec/failing_scenario.spec.ts
- +15 −4 integration/cucumber/spec/passing_scenario.spec.ts
- +86 −11 integration/cucumber/spec/pending_scenarios.spec.ts
- +15 −4 integration/cucumber/spec/scenario_outlines.spec.ts
- +19 −5 integration/cucumber/spec/tags.spec.ts
- +15 −4 integration/cucumber/spec/themes.spec.ts
- +15 −4 integration/cucumber/spec/timed_out_scenario.spec.ts
- +2 −4 integration/cucumber/src/CucumberRunner.ts
- +4 −4 integration/cucumber/src/CucumberRunnerBuilder.ts
- +19 −0 integration/testing-tools/bin/parallel-mocha.js
- +3 −0 integration/testing-tools/package.json
- +30 −30 package-lock.json
- +1 −0 package.json
- +45 −0 packages/core/spec/io/ErrorSerialiser.spec.ts
- +7 −0 packages/core/src/errors/UnknownError.ts
- +1 −0 packages/core/src/errors/index.ts
- +9 −0 packages/core/src/io/ErrorSerialiser.ts
- +43 −0 packages/cucumber/spec/gherkin/feature-files/Cache.spec.ts
- +2 −2 packages/cucumber/spec/gherkin/feature-files/FeatureFileLoader.spec.ts
- +6 −4 packages/cucumber/spec/gherkin/feature-files/FeatureFileMapper.spec.ts
- +10 −0 packages/cucumber/src/adapters/CucumberFormatterOptions.ts
- +4 −1 packages/cucumber/src/adapters/Dependencies.ts
- +22 −40 packages/cucumber/src/adapters/cucumber-0.ts
- +2 −2 packages/cucumber/src/adapters/cucumber-2.ts
- +130 −3 packages/cucumber/src/adapters/cucumber-3.ts
- +15 −4 packages/cucumber/src/adapters/index.ts
- +7 −0 packages/cucumber/src/errors/AmbiguousStepDefinitionError.ts
- +1 −0 packages/cucumber/src/errors/index.ts
- +37 −0 packages/cucumber/src/gherkin/feature-files/Cache.ts
- +2 −1 packages/cucumber/src/gherkin/feature-files/FeatureFileLoader.ts
- +4 −3 packages/cucumber/src/gherkin/feature-files/FeatureFileMap.ts
- +6 −1 packages/cucumber/src/gherkin/feature-files/FeatureFileMapper.ts
- +7 −0 packages/cucumber/src/gherkin/feature-files/errors/ItemNotFoundError.ts
- +7 −0 packages/cucumber/src/gherkin/feature-files/errors/UnableToRetrieveFeatureFileMap.ts
- +3 −1 packages/cucumber/src/gherkin/feature-files/errors/index.ts
- +1 −0 packages/cucumber/src/gherkin/feature-files/index.ts
- +1 −0 packages/cucumber/src/gherkin/model/Scenario.ts
- +6 −0 packages/cucumber/src/index.ts
- +2 −0 packages/cucumber/src/register.ts
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -2,7 +2,8 @@ | ||
"extends": "./tsconfig", | ||
"include": [ | ||
"src/**/*.ts", | ||
"spec/**/*.ts", | ||
"features/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -2,7 +2,8 @@ | ||
"extends": "./tsconfig", | ||
"include": [ | ||
"src/**/*.ts", | ||
"spec/**/*.ts", | ||
"features/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,7 @@ | ||
# Node | ||
node_modules | ||
*.log | ||
|
||
# Build artifacts | ||
.nyc_output | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,12 @@ | ||
import { defineSupportCode } from 'cucumber'; | ||
|
||
defineSupportCode(({ Given }) => { | ||
|
||
Given(/^.*step (?:.*) passes$/, function() { | ||
return void 0; | ||
}); | ||
|
||
Given(/^.*step (?:.*) passes$/, function() { | ||
return void 0; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,8 @@ | ||
import { defineSupportCode } from 'cucumber'; | ||
|
||
defineSupportCode(({ After }) => { | ||
|
||
After(function() { | ||
// no-op | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,8 @@ | ||
import { defineSupportCode } from 'cucumber'; | ||
|
||
defineSupportCode(({ Before }) => { | ||
|
||
Before(function() { | ||
// no-op | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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(), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,8 @@ | ||
import { defineSupportCode } from 'cucumber'; | ||
|
||
defineSupportCode(({ Before }) => { | ||
|
||
Before({ tags: '@wip' }, function() { | ||
return 'pending'; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "./tsconfig", | ||
"include": [ | ||
"src/**/*.ts", | ||
"spec/**/*.ts", | ||
"features/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -3,4 +3,3 @@ Feature: Serenity/JS recognises a passing scenario | ||
Scenario: A passing scenario | ||
|
||
Given a step that passes | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.