UNPKG

quoad

Version:

Serenity/JS: Next generation acceptance testing library for modern web applications.

58 lines (50 loc) 2.75 kB
import 'mocha'; import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools'; import { Timestamp } from '@serenity-js/core'; import { ActivityFinished, ActivityStarts, SceneFinished, SceneFinishes, SceneStarts, SceneTagged, TestRunFinished, TestRunFinishes, TestRunnerDetected, TestRunStarts, } from '@serenity-js/core/lib/events'; import { CorrelationId, ExecutionSuccessful, FeatureTag, Name } from '@serenity-js/core/lib/model'; import { cucumber, cucumberVersion } from '../src'; describe(`@serenity-js/cucumber with Cucumber ${ cucumberVersion() }`, function () { it('recognises a passing scenario', () => cucumber('features/passing_scenario.feature', 'common.steps.ts') .then(ifExitCodeIsOtherThan(0, logOutput)) .then(result => { expect(result.exitCode).to.equal(0); let currentSceneId: CorrelationId; PickEvent.from(result.events) .next(TestRunStarts, event => expect(event.timestamp).to.be.instanceof(Timestamp)) .next(SceneStarts, event => { expect(event.details.name).to.equal(new Name('A passing scenario')) expect(event.details.location.path.value).to.match(/features\/passing_scenario.feature$/) expect(event.details.location.line).to.equal(3); expect(event.details.location.column).to.equal(3); currentSceneId = event.sceneId; }) .next(TestRunnerDetected, event => expect(event.name).to.equal(new Name('Cucumber'))) .next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises a passing scenario'))) .next(ActivityStarts, event => expect(event.details.name).to.equal(new Name('Given a step that passes'))) .next(ActivityFinished, event => expect(event.outcome).to.equal(new ExecutionSuccessful())) .next(SceneFinishes, event => { expect(event.sceneId).to.equal(currentSceneId); }) .next(SceneFinished, event => { expect(event.sceneId).to.equal(currentSceneId); expect(event.outcome).to.equal(new ExecutionSuccessful()); }) .next(TestRunFinishes, event => expect(event.timestamp).to.be.instanceof(Timestamp)) .next(TestRunFinished, event => expect(event.timestamp).to.be.instanceof(Timestamp)) ; }) ); });