Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(cucumber): ensure async events are correctly synchronised before …
…the test run finishes

SerenityBDDReporter emits reports after the test run completes

#405
  • Loading branch information
jan-molak committed Jan 23, 2020
1 parent d39bc7c commit d69aeae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/cucumber/src/listeners/cucumber-0.ts
Expand Up @@ -87,8 +87,10 @@ export = function ({ serenity, notifier, loader, cache }: Dependencies) {
notifier.scenarioFinished(map.get(Scenario).onLine(line), map.getFirst(Feature), scenarioOutcomeFrom(result));
});

this.registerHandler('AfterFeatures', features => {
notifier.testRunFinished();
this.registerHandler('AfterFeatures', (features, callback) => {
serenity.waitForNextCue()
.then(() => notifier.testRunFinished())
.then(() => callback(), error => callback(error));
});
};
};
Expand Down
5 changes: 4 additions & 1 deletion packages/cucumber/src/listeners/cucumber-3.ts
Expand Up @@ -11,7 +11,10 @@ export = function (dependencies: Dependencies) {
});

AfterAll(function () {
dependencies.notifier.testRunFinished();
return dependencies.serenity.waitForNextCue()
.then(() => {
dependencies.notifier.testRunFinished();
});
});
});

Expand Down
5 changes: 4 additions & 1 deletion packages/cucumber/src/listeners/cucumber-4.ts
Expand Up @@ -11,7 +11,10 @@ export = function (dependencies: Dependencies) {
});

AfterAll(function () {
dependencies.notifier.testRunFinished();
return dependencies.serenity.waitForNextCue()
.then(() => {
dependencies.notifier.testRunFinished();
});
});

return cucumberEventProtocolAdapter(dependencies);
Expand Down

0 comments on commit d69aeae

Please sign in to comment.