Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.when(InteractionFinished, ({ value, outcome }: InteractionFinished) => {
// todo: clean up
if (this.stage.theShowHasStarted() && outcome.isWorseThan(ImplementationPending)) {
const id = CorrelationId.create();
this.stage.manager.notifyOf(new AsyncOperationAttempted(
new Description(`[${ this.constructor.name }] Taking screenshot of '${ value.name.value }'...`),
id,
));
BrowseTheWeb.as(this.stage.theActorInTheSpotlight()).takeScreenshot()
.then(screenshot => {
this.stage.manager.notifyOf(new ArtifactGenerated(
value.name,
Photo.fromBase64(screenshot),
));
this.stage.manager.notifyOf(new AsyncOperationCompleted(
new Description(`[${ this.constructor.name }] Took screenshot of '${ value.name.value }'`),
id,
));
})
.catch(error => {
it('associates the background with the feature', parse('backgrounds.feature', map => {
const feature = map.get(Feature).onLine(1);
expect(feature.background).to.equal(
new Background(
new FileSystemLocation(fixtures.join(new Path('backgrounds.feature')), 3, 3),
new Name('The one that provides some context'),
new Description('Once upon a time, there was a test suite.'),
[
new Step(
new FileSystemLocation(fixtures.join(new Path('backgrounds.feature')), 7, 5),
new Name('Given a prerequisite'),
),
],
));
}));
it('maps a scenario with a single-line description', parse('names_and_descriptions.feature', map => {
const scenario = map.get(Scenario).onLine(8);
expect(scenario.name).to.equal(new Name('The one with a description'));
expect(scenario.description).to.equal(new Description('Description of a scenario'));
}));
it('maps the scenario template', parse('scenario_outlines.feature', map => {
const
scenario = map.get(ScenarioOutline).onLine(3),
path = fixtures.join(new Path('scenario_outlines.feature'));
expect(scenario).to.equal(new ScenarioOutline(
new FileSystemLocation(path, 3, 3),
new Name('The one with examples'),
new Description('Description of the scenario with examples'),
[
new Step(
new FileSystemLocation(path, 7, 5),
new Name('Given step with a '),
),
],
{
14: new ScenarioParameters(
new Name('Name of the example set'),
new Description('Description of the example set'),
{ parameter: 'value one' },
),
15: new ScenarioParameters(
new Name('Name of the example set'),
new Description('Description of the example set'),
{ parameter: 'value two' },
it('captures information about scenario background', () => {
given(reporter).isNotifiedOfFollowingEvents(
new SceneStarts(defaultCardScenario),
new SceneBackgroundDetected(new Name('Background title'), new Description('Background description')),
new SceneFinished(defaultCardScenario, new ExecutionSuccessful()),
new TestRunFinished(),
);
const report: SerenityBDDReport = stageManager.notifyOf.firstCall.lastArg.artifact.map(_ => _);
expect(report.backgroundTitle).to.equal('Background title');
expect(report.backgroundDescription).to.equal('Background description');
});
it('maps a scenario with a multi-line description', parse('names_and_descriptions.feature', map => {
const scenario = map.get(Scenario).onLine(14);
expect(scenario.name).to.equal(new Name('The one with a multi-line description'));
expect(scenario.description).to.equal(new Description('A multi-line\n\ndescription\nof a scenario'));
}));
});
.then(screenshot => {
this.stage.manager.notifyOf(new ArtifactGenerated(
value.name,
Photo.fromBase64(screenshot),
));
this.stage.manager.notifyOf(new AsyncOperationCompleted(
new Description(`[${ this.constructor.name }] Took screenshot of '${ value.name.value }'`),
id,
));
})
.catch(error => {
outline.examples.filter(e => e.tableHeader !== undefined).forEach(examples => {
const
exampleSetName = new Name(examples.name),
exampleSetDescription = examples.description && new Description(examples.description),
variableCells = examples.tableHeader.cells;
examples.tableBody.forEach(values => {
const
valueCells = values.cells,
steps = background ? background.steps : [];
outline.steps.forEach(scenarioOutlineStep => {
const
interpolatedStepText = this.interpolate(scenarioOutlineStep.text, variableCells, valueCells),
interpolatedStepArgument = this.interpolateStepArgument(scenarioOutlineStep.argument, variableCells, valueCells);
steps.push(new Step(
new FileSystemLocation(
path,
scenarioOutlineStep.location.line,
new Description('Description of the scenario with more examples'),
[
new Step(
new FileSystemLocation(path, 21, 5),
new Name('Given step with a '),
),
],
{
28: new ScenarioParameters(
new Name('Name of the first set of examples'),
new Description('Description of the first set of examples'),
{ parameter: 'value one' },
),
29: new ScenarioParameters(
new Name('Name of the first set of examples'),
new Description('Description of the first set of examples'),
{ parameter: 'value two' },
),
36: new ScenarioParameters(
new Name('Name of the second set of examples'),
new Description('Description of the second set of examples'),
{ parameter: 'value three' },
),
37: new ScenarioParameters(
new Name('Name of the second set of examples'),
new Description('Description of the second set of examples'),
{ parameter: 'value four' },
),
},
));
}));
});
}, {});
parameters[values.location.line] = new ScenarioParameters(
exampleSetName,
exampleSetDescription,
scenarioParameters,
);
map.set(new Scenario(
new FileSystemLocation(
path,
values.location.line,
values.location.column,
),
new Name(outline.name),
outline.description && new Description(outline.description),
steps,
this.tagsFrom(document.feature.tags, outline.tags, examples.tags),
new FileSystemLocation(
path,
outline.location.line,
outline.location.column,
),
)).onLine(values.location.line);
});
});