Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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('correctly recognises Cucumber Event Protocol events', () => {
emitAllFrom(require('./samples/scenario-with-hooks.json'));
const expectedScenarioDetails = new ScenarioDetails(
new Name('Hooks'),
new Category('Event Protocol'),
new FileSystemLocation(
new Path('features/tasty-cucumber.feature'),
3,
3,
),
);
return serenity.waitForNextCue().then(() => {
PickEvent.from(recorder.events)
.next(SceneStarts, e => expect(e.value).to.equal(expectedScenarioDetails))
.next(TestRunnerDetected, e => expect(e.value).to.equal(new Name('Cucumber')))
.next(SceneTagged, e => expect(e.tag).to.equal(new FeatureTag('Event Protocol')))
.next(TaskStarts, e => expect(e.value.name).to.equal(new Name('Given I have a tasty cucumber in my belly')))
.next(TaskFinished, e => {
expect(e.value.name).to.equal(new Name('Given I have a tasty cucumber in my belly'));
it('maps the background with name and description', parse('backgrounds.feature', map => {
const firstBackground = map.get(Background).onLine(3);
expect(firstBackground.name).to.equal(new Name('The one that provides some context'));
expect(firstBackground.description).to.equal(new Description('Once upon a time, there was a test suite.'));
expect(firstBackground.steps).to.deep.equal([
new Step(
new FileSystemLocation(fixtures.join(new Path('backgrounds.feature')),
7,
5,
),
new Name('Given a prerequisite'),
),
]);
}));
));
expect(outline.parameters[60]).to.equal(new ScenarioParameters(
new Name(''),
undefined,
{ username: 'admin', password: 'P@ssw0rd1' },
));
expect(outline.parameters[61]).to.equal(new ScenarioParameters(
new Name(''),
undefined,
{ username: 'editor', password: 'P@ssw0rd2' },
));
expect(map.get(Scenario).onLine(60).steps[0])
.to.equal(new Step(
new FileSystemLocation(path, 53, 5),
new Name('Given the user logs in as admin with the following credentials:\n| username | admin |\n| password | P@ssw0rd1 |'),
));
expect(map.get(Scenario).onLine(61).steps[0])
.to.equal(new Step(
new FileSystemLocation(path, 53, 5),
new Name('Given the user logs in as editor with the following credentials:\n| username | editor |\n| password | P@ssw0rd2 |'),
));
}));
});
.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')))
import { FileSystemLocation, Path } from '@serenity-js/core/lib/io';
import { Category, Name, Photo, ScenarioDetails } from '@serenity-js/core/lib/model';
export const defaultCardScenario = new ScenarioDetails(
new Name('Paying with a default card'),
new Category('Online Checkout'),
new FileSystemLocation(
new Path(`payments/checkout.feature`),
),
);
export const voucherScenario = new ScenarioDetails(
new Name('Paying with a voucher'),
new Category('Online Checkout'),
new FileSystemLocation(
new Path(`payments/checkout.feature`),
),
);
export const photo = new Photo('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEW01FWbeM52AAAACklEQVR4nGNiAAAABgADNjd8qAAAAABJRU5ErkJggg==');
.next(TaskFinished, e => {
expect(e.value.name).to.equal(new Name('Given I have a pending step'));
expect(e.outcome).to.be.instanceOf(ImplementationPending);
})
.next(TaskStarts, e => expect(e.value.name).to.equal(new Name(`Then I should implement it`)))
.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')))
.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')))
new FileSystemLocation(path, 14, 7),
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 value one'),
),
],
[],
new FileSystemLocation(path, 3, 3),
));
expect(map.get(Scenario).onLine(15)).to.equal(new Scenario(
new FileSystemLocation(path, 15, 7),
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 value two'),
),
],
[],
new FileSystemLocation(path, 3, 3),
));
}));
});