How to use the cucumber.Before function in cucumber

To help you get started, we’ve selected a few cucumber examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github screwdriver-cd / screwdriver / features / step_definitions / events.js View on Github external
'use strict';

const Assert = require('chai').assert;
const request = require('../support/request');
const { Before, Given, Then } = require('cucumber');

const TIMEOUT = 240 * 1000;

Before('@events', function hook() {
    this.repoName = 'functional-events';

    // Reset shared information
    this.pipelineId = null;
    this.eventId = null;
    this.jwt = null;
});

Given(/^an existing pipeline with the workflow:$/, { timeout: TIMEOUT }, function step(table) {
    return this.ensurePipelineExists({ repoName: this.repoName })
        .then(() => table);
});

Given(/^"calvin" has admin permission to the pipeline$/, () => null);

Then(/^an event is created$/, { timeout: TIMEOUT }, function step() {
github screwdriver-cd / screwdriver / features / step_definitions / sd-cmd.js View on Github external
'use strict';

const Assert = require('chai').assert;
const request = require('../support/request');
const { Before, Given, When, Then } = require('cucumber');

const TIMEOUT = 240 * 1000;

Before({
    tags: '@sd-cmd'
}, function hook() {
    this.repoOrg = this.testOrg;
    this.repoName = 'functional-commands';
    this.pipelineId = null;
    this.configPipelineId = null;
    this.buildPipelineIds = {};
    this.jwt = null;
    this.image = null;
    this.command = null;
    this.commandNamespace = 'screwdriver-cd-test';

    return request({ // TODO : perform this in the before-hook for all func tests
        method: 'GET',
        url: `${this.instance}/${this.namespace}/auth/token?api_token=${this.apiToken}`,
        followAllRedirects: true,
github screwdriver-cd / screwdriver / features / step_definitions / authorization.js View on Github external
'use strict';

const Assert = require('chai').assert;
const request = require('../support/request');
const jwt = require('jsonwebtoken');
const TIMEOUT = 240 * 1000;
const { Before, Given, Then } = require('cucumber');

Before('@auth', function hook() {
    this.repoOrg = this.testOrg;
    this.repoName = 'functional-auth';
    this.pipelineId = null;
});

Given(/^an existing repository with these users and permissions:$/, table => table);

Given(/^an existing pipeline with that repository$/, () => null);

Given(/^"([^"]*)" is logged in$/, { timeout: TIMEOUT }, function step(user) {
    if (!(this.apiToken)) {
        throw new Error('insufficient set up, missing access key');
    }

    return this.getJwt(this.apiToken).then((response) => {
        const accessToken = response.body.token;
github screwdriver-cd / screwdriver / features / step_definitions / metadata.js View on Github external
'use strict';

const Assert = require('chai').assert;
const request = require('../support/request');
const sdapi = require('../support/sdapi');
const { Before, Given, Then } = require('cucumber');

const TIMEOUT = 240 * 1000;

Before({
    tags: '@metadata'
}, function hook() {
    this.repoOrg = this.testOrg;
    this.repoName = 'functional-metadata';
    this.pipelineId = null;
    this.eventId = null;
    this.meta = null;
    this.jwt = null;
});

Given(/^a metadata starts with an empty object$/, { timeout: TIMEOUT }, () => null);

Then(/^the "(BAR|BAZ)" job is started$/, { timeout: TIMEOUT }, function step(jobName) {
    switch (jobName) {
    case 'BAR':
        this.jobName = 'second';
github screwdriver-cd / screwdriver / features / step_definitions / workflow.js View on Github external
'use strict';

const Assert = require('chai').assert;
const github = require('../support/github');
const sdapi = require('../support/sdapi');
const { Before, Given, When, Then } = require('cucumber');

const TIMEOUT = 240 * 1000;
const WAIT_TIME = 3;

Before({
    tags: '@workflow'
}, function hook() {
    this.repoOrg = this.testOrg;
    this.repoName = 'functional-workflow';
    this.pipelineId = null;
    this.builds = null;
});

Given(/^an existing pipeline on "(.*)" branch with the workflow jobs:$/, {
    timeout: TIMEOUT
}, function step(branch, table) {
    return this.getJwt(this.apiToken)
        .then((response) => {
            this.jwt = response.body.token;

            return github.createBranch(branch, this.repoOrg, this.repoName);

cucumber

The official JavaScript implementation of Cucumber.

MIT
Latest version published 3 years ago

Package Health Score

64 / 100
Full package analysis