@serenity-js/cucumber
Version:
Serenity/JS test runner adapter for seamless integration with any version of Cucumber.js, facilitating BDD-style test automation and leveraging Serenity/JS reporting capabilities
35 lines (26 loc) • 1.1 kB
text/typescript
import { ExecutionFailedWithError, ExecutionSuccessful } from '@serenity-js/core/lib/model';
import { cucumberEventProtocolAdapter } from './CucumberEventProtocolAdapter';
import type { Dependencies } from './Dependencies';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export = function (dependencies: Dependencies) {
const { BeforeAll, After, AfterAll } = dependencies.cucumber;
BeforeAll(function () {
dependencies.notifier.testRunStarts();
});
After(function () {
dependencies.notifier.scenarioFinishes();
return dependencies.serenity.waitForNextCue();
});
AfterAll(async function () {
dependencies.notifier.testRunFinishes();
try {
await dependencies.serenity.waitForNextCue()
dependencies.notifier.testRunFinished(new ExecutionSuccessful());
}
catch(error) {
dependencies.notifier.testRunFinished(new ExecutionFailedWithError(error));
throw error;
}
});
return cucumberEventProtocolAdapter(dependencies);
};