UNPKG

@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

36 lines (27 loc) 1.19 kB
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) { dependencies.cucumber.defineSupportCode(({ BeforeAll, After, AfterAll }) => { 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); };