Skip to content
Permalink
Browse files
feat(protractor): Photographer takes screenshots when an Interaction …
…fails
  • Loading branch information
jan-molak committed Mar 25, 2019
1 parent 8c3857b commit 5ad6468282d994508d6f092957f11a168125896c
Showing 50 changed files with 554 additions and 173 deletions.
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import {
ActivityFinished,
ActivityStarts,
@@ -39,7 +39,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(1);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A passing 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 passing scenario')))
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import { AssertionError } from '@serenity-js/core';
import {
ActivityFinished,
@@ -40,7 +40,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(1);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('An assertion failure 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 scenario failing due to an assertion error')))
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import { SceneTagged } from '@serenity-js/core/lib/events';
import { CapabilityTag, FeatureTag } from '@serenity-js/core/lib/model';

@@ -32,7 +32,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneTagged, event => expect(event.tag).to.equal(new CapabilityTag('example capability')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises capabilities')))
;
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import { ActivityStarts } from '@serenity-js/core/lib/events';
import { Name } from '@serenity-js/core/lib/model';

@@ -32,7 +32,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(
'Given a step that receives a table:\n' +
'| Developer | Website |\n' +
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import { FeatureNarrativeDetected, SceneDescriptionDetected, SceneStarts } from '@serenity-js/core/lib/events';
import { Description, Name } from '@serenity-js/core/lib/model';

@@ -32,7 +32,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('First scenario')))
.next(FeatureNarrativeDetected, event => {
expect(event.description).to.equal(new Description(
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import { ActivityStarts } from '@serenity-js/core/lib/events';
import { Name } from '@serenity-js/core/lib/model';

@@ -32,7 +32,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(
'Given a step that receives a doc string:\n' +
'Dear customer,\n' +
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import {
ActivityFinished,
ActivityStarts,
@@ -39,7 +39,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(1);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A failing 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 failing scenario')))
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import {
ActivityFinished,
ActivityStarts,
@@ -39,7 +39,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A passing 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 passing scenario')))
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import {
ActivityFinished,
ActivityStarts,
@@ -52,13 +52,13 @@ describe('@serenity-js/cucumber', function() {
then(res => {
// expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario with steps marked as pending')))
.next(TestRunnerDetected, event => expect(event.value).to.equal(new Name('Cucumber')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises pending scenarios')))
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(`Given a step that's marked as pending`)))
.next(ActivityFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
.next(ActivityFinished, event => expect(event.outcome.constructor).to.equal(ImplementationPending))
.next(SceneFinished, event => expect(event.outcome.constructor).to.equal(ImplementationPending))
;
}));

@@ -96,13 +96,13 @@ describe('@serenity-js/cucumber', function() {
then(res => {
// expect(res.exitCode).to.equal(0); // cucumber 3 ignores the --no-strict mode

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario with steps that have not been implemented yet')))
.next(TestRunnerDetected, event => expect(event.value).to.equal(new Name('Cucumber')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises pending scenarios')))
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(`Given a step that hasn't been implemented yet`)))
.next(ActivityFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
.next(ActivityFinished, event => expect(event.outcome.constructor).to.equal(ImplementationPending))
.next(SceneFinished, event => expect(event.outcome.constructor).to.equal(ImplementationPending))
;
}));

@@ -132,7 +132,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
// expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario which tag marks it as pending')))
.next(TestRunnerDetected, event => expect(event.value).to.equal(new Name('Cucumber')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises pending scenarios')))
@@ -142,7 +142,7 @@ describe('@serenity-js/cucumber', function() {
.next(ActivityFinished, event => expect(event.outcome).to.equal(new ExecutionSkipped()))
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(`And step number three that fails with generic error`)))
.next(ActivityFinished, event => expect(event.outcome).to.equal(new ExecutionSkipped()))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
.next(SceneFinished, event => expect(event.outcome.constructor).to.equal(ImplementationPending))
;
}));

@@ -165,17 +165,17 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(1);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name).to.equal(new Name('A scenario which tag marks it as pending')))
.next(TestRunnerDetected, event => expect(event.value).to.equal(new Name('Cucumber')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises pending scenarios')))
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(`Given step number one that passes`)))
.next(ActivityFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
.next(ActivityFinished, event => expect(event.outcome.constructor).to.equal(ImplementationPending))
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(`And step number two that is marked as pending`)))
.next(ActivityFinished, event => expect(event.outcome).to.equal(new ExecutionSkipped()))
.next(ActivityStarts, event => expect(event.value.name).to.equal(new Name(`And step number three that fails with generic error`)))
.next(ActivityFinished, event => expect(event.outcome).to.equal(new ExecutionSkipped()))
.next(SceneFinished, event => expect(event.outcome).to.equal(new ImplementationPending()))
.next(SceneFinished, event => expect(event.outcome.constructor).to.equal(ImplementationPending))
;
}));
});
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import {
SceneFinished,
SceneParametersDetected,
@@ -46,7 +46,7 @@ describe('@serenity-js/cucumber', function() {
expectedExamplesName = new Name('Example results'),
expectedExamplesDescription = new Description('Description of the examples');

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneSequenceDetected, event => {
expect(event.value.name).to.equal(expectedScenarioName);
expect(event.value.category).to.equal(expectedScenarioCategory);
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import { SceneStarts, SceneTagged } from '@serenity-js/core/lib/events';
import { ArbitraryTag, FeatureTag } from '@serenity-js/core/lib/model';

@@ -33,7 +33,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name.value).to.equal('A tagged scenario'))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises tags at multiple levels')))
.next(SceneTagged, event => expect(event.tag).to.equal(new ArbitraryTag('@feature-tag')))
@@ -65,7 +65,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneStarts, event => expect(event.value.name.value).to.equal('More tagged scenarios'))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises tags at multiple levels')))
.next(SceneTagged, event => expect(event.tag).to.equal(new ArbitraryTag('@feature-tag')))
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import { SceneTagged } from '@serenity-js/core/lib/events';
import { CapabilityTag, FeatureTag, ThemeTag } from '@serenity-js/core/lib/model';

@@ -32,7 +32,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(0);

Pick.from(res.events)
PickEvent.from(res.events)
.next(SceneTagged, event => expect(event.tag).to.equal(new ThemeTag('example theme')))
.next(SceneTagged, event => expect(event.tag).to.equal(new CapabilityTag('example capability')))
.next(SceneTagged, event => expect(event.tag).to.equal(new FeatureTag('Serenity/JS recognises capabilities and themes')))
@@ -1,4 +1,4 @@
import { expect, ifExitCodeIsOtherThan, logOutput, Pick, SpawnResult } from '@integration/testing-tools';
import { expect, ifExitCodeIsOtherThan, logOutput, PickEvent } from '@integration/testing-tools';
import {
ActivityFinished,
ActivityStarts,
@@ -39,7 +39,7 @@ describe('@serenity-js/cucumber', function() {
then(res => {
expect(res.exitCode).to.equal(1);

Pick.from(res.events)
PickEvent.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')))
@@ -0,0 +1,19 @@
import { DomainEvent } from '@serenity-js/core/lib/events';
import { Stage, StageCrewMember } from '@serenity-js/core/lib/stage';

export class EventRecorder implements StageCrewMember {

constructor(
public readonly events: DomainEvent[] = [],
private readonly stage: Stage = null,
) {
}

assignedTo(stage: Stage) {
return new EventRecorder(this.events, stage);
}

notifyOf(event: DomainEvent) {
this.events.push(event);
}
}
@@ -1,7 +1,7 @@
import { DomainEvent } from '@serenity-js/core/lib/events';

export class Pick {
static from = (events: DomainEvent[]) => new Pick(events);
export class PickEvent {
static from = (events: DomainEvent[]) => new PickEvent(events);

constructor(private events: DomainEvent[]) {
}
@@ -1,14 +1,14 @@
import { DomainEvent } from '@serenity-js/core/lib/events';
import { StageCrewMember, StageManager } from '@serenity-js/core/lib/stage';
import { Stage, StageCrewMember } from '@serenity-js/core/lib/stage';
import { JSONObject } from 'tiny-types';
import { DTO } from './DTO';

export class ChildProcessReporter implements StageCrewMember {
constructor(private readonly stageManager: StageManager = null) {
constructor(private readonly stage: Stage = null) {
}

assignedTo(stageManager: StageManager): StageCrewMember {
return new ChildProcessReporter(stageManager);
assignedTo(stage: Stage): StageCrewMember {
return new ChildProcessReporter(stage);
}

notifyOf(event: DomainEvent): void {
@@ -0,0 +1,10 @@
import { DomainEvent } from '@serenity-js/core/lib/events';
import { StageCrewMember } from '@serenity-js/core/lib/stage';

export function givenFollowingEvents(...events: DomainEvent[]) {
return ({
areSentTo: (crewMember: StageCrewMember) => {
events.forEach(event => crewMember.notifyOf(event));
},
});
}
@@ -1,4 +1,6 @@
export * from './child-process-reporter';
export * from './expect';
export * from './Pick';
export * from './spawner';
export * from './givenFollowingEvents';
export * from './PickEvent';
export * from './EventRecorder';
@@ -1,16 +1,16 @@
import { DomainEvent } from '../src/events';
import { StageCrewMember, StageManager } from '../src/stage';
import { Stage, StageCrewMember } from '../src/stage';

export class Recorder implements StageCrewMember {

constructor(
public readonly events: DomainEvent[] = [],
private readonly stageManager: StageManager = null,
private readonly stage: Stage = null,
) {
}

assignedTo(stageManager: StageManager) {
return new Recorder(this.events, stageManager);
assignedTo(stage: Stage) {
return new Recorder(this.events, stage);
}

notifyOf(event: DomainEvent) {

0 comments on commit 5ad6468

Please sign in to comment.