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): timed out steps and scenarios are correctly reported
affects: @serenity-js/core, @serenity-js/cucumber, @integration/cucumber, @serenity-js-examples/cucumber
- Loading branch information
Showing
with
102 additions
and 19 deletions.
- +1 −1 examples/cucumber/features/reporting_results/narrative.txt
- +14 −0 examples/cucumber/features/reporting_results/reports_timed_out_scenarios.feature
- +1 −1 examples/cucumber/features/step_definitions/sample.steps.ts
- +1 −1 integration/cucumber/features/step_definitions/callback.steps.ts
- +1 −1 integration/cucumber/features/step_definitions/promise.steps.ts
- +0 −4 integration/cucumber/features/step_definitions/synchronous.steps.ts
- +6 −0 integration/cucumber/features/timed_out_scenario.feature
- +53 −0 integration/cucumber/spec/timed_out_scenario.spec.ts
- +0 −1 packages/core/src/stage/crew/serenity-bdd-reporter/ErrorParser.ts
- +25 −10 packages/cucumber/src/listener/Notifier.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
@@ -1,4 +1,4 @@ | ||
Reporting results | ||
|
||
Narrative: | ||
In order to quickly learn how to use Serenity/JS with Cucumber | ||
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,14 @@ | ||
Feature: Reports timed out scenarios | ||
|
||
In order to see how Serenity/JS reports a timed out Cucumber scenario | ||
As a curious developer | ||
I'd like to see an example implementation | ||
|
||
Scenario: A timed out scenario | ||
|
||
Here's an example of a scenario that times out. | ||
Should at least one of the steps time out, the subsequent steps are skipped and the entire scenario is marked as timed out. | ||
|
||
Given a step that passes | ||
And a step that times out | ||
And 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
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
@@ -23,7 +23,7 @@ export = function() { | ||
done(); | ||
}); | ||
|
||
this.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
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
@@ -20,8 +20,4 @@ export = function() { | ||
this.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,6 @@ | ||
Feature: Serenity/JS recognises a timed out scenario | ||
|
||
Scenario: A timed out scenario | ||
|
||
Given a step that times out | ||
|
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,53 @@ | ||
import { expect, ifExitCodeIsOtherThan, logOutput } from '@integration/testing-tools'; | ||
import { | ||
ActivityFinished, | ||
ActivityStarts, | ||
SceneFinished, | ||
SceneStarts, | ||
SceneTagged, | ||
TestRunnerDetected, | ||
} from '@serenity-js/core/lib/events'; | ||
import { ExecutionFailedWithError, FeatureTag, 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([ | ||
'promise', | ||
'callback', | ||
]). | ||
it('recognises a timed out scenario', (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/timed_out_scenario.feature', | ||
). | ||
then(ifExitCodeIsOtherThan(1, logOutput)). | ||
then(res => { | ||
expect(res.exitCode).to.equal(1); | ||
|
||
expect(res.events).to.have.lengthOf(6); | ||
|
||
Pick.from(res.events) | ||
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A timed out scenario'))) | ||
.next(TestRunnerDetected, event => expect(event.value).to.equal(new Name('Cucumber'))) | ||
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises a timed out scenario'))) | ||
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name('Given a step that times out'))) | ||
.next(ActivityFinished, event => { | ||
expect(event.outcome).to.be.instanceOf(ExecutionFailedWithError); | ||
expect((event.outcome as ExecutionFailedWithError).error.message).to.equal('function timed out after 100 milliseconds'); | ||
}) | ||
.next(SceneFinished, event => { | ||
expect(event.outcome).to.be.instanceOf(ExecutionFailedWithError); | ||
expect((event.outcome as ExecutionFailedWithError).error.message).to.equal('function timed out after 100 milliseconds'); | ||
}) | ||
; | ||
})); | ||
}); |
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,6 @@ import * as ErrorStackParser from 'error-stack-parser'; | ||
|
||
export class ErrorParser { | ||
parse(error: Error) { | ||
return { | ||
errorType: error.name, | ||
message: error.message, | ||
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