Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(cucumber): support for Cucumber 5.x
affects: @serenity-js/cucumber, @integration/cucumber-1-runner, @integration/cucumber-2-runner, @integration/cucumber-3-runner, @integration/cucumber-4-runner, @integration/cucumber-5-runner, @integration/cucumber, @integration/testing-tools, @serenity-js-examples/cucumber-domain-level-testing, @serenity-js-examples/cucumber-reporting ISSUES CLOSED: Closes #28
- Loading branch information
Showing
36 changed files
with
244 additions
and
36 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Cucumber 4.x runner | ||
|
||
This is an internal test module that embeds Cucumber 4.2.1 | ||
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/v4.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "@integration/cucumber-5-runner", | ||
"version": "0.0.0", | ||
"description": "Cucumber JS 5.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": "5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/cucumber": "4.0.4" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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( | ||
...params, | ||
); |
9 changes: 9 additions & 0 deletions
9
integration/cucumber-5-runner/src/step_definitions/ambiguous.steps.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Given } from 'cucumber'; | ||
|
||
Given(/^.*step (?:.*) passes$/, function() { | ||
return void 0; | ||
}); | ||
|
||
Given(/^.*step (?:.*) passes$/, function() { | ||
return void 0; | ||
}); |
27 changes: 27 additions & 0 deletions
27
integration/cucumber-5-runner/src/step_definitions/callback.steps.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Given, TableDefinition } from 'cucumber'; | ||
|
||
type Callback = (error?: Error, pending?: string) => void; | ||
|
||
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); | ||
}); |
27 changes: 27 additions & 0 deletions
27
integration/cucumber-5-runner/src/step_definitions/promise.steps.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Given, TableDefinition } from 'cucumber'; | ||
|
||
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); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
integration/cucumber-5-runner/src/step_definitions/synchronous.steps.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Given, TableDefinition } from 'cucumber'; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { After } from 'cucumber'; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Before } from 'cucumber'; | ||
|
||
Before(function() { | ||
// no-op | ||
}); |
11 changes: 11 additions & 0 deletions
11
integration/cucumber-5-runner/src/support/configure_serenity.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ChildProcessReporter } from '@integration/testing-tools'; | ||
import { serenity } from '@serenity-js/core'; | ||
import { DebugReporter } from '@serenity-js/core/lib/stage'; | ||
import { setDefaultTimeout } from 'cucumber'; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Before } from 'cucumber'; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
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
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
Oops, something went wrong.