How to use the cucumber.setWorldConstructor 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 harver-engineering / bat / test / features / support / setup.js View on Github external
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

const url = require('url');
const http = require('http');
const { setWorldConstructor, After, AfterAll, Before, BeforeAll, Given, When, Then } = require('cucumber');
const { registerHooks, World: BaseWorld, registerSteps } = require('../../../src/index');

class World extends BaseWorld {
    constructor() {
        super();
    }
}

setWorldConstructor(World);
registerHooks({ After, AfterAll, Before, BeforeAll });
registerSteps({ Given, Then, When });

process.env.GRAPHQL_BASE_URL = 'http://localhost:3000/graphql';

// a custom login step
Given('I am logged in as a {string}', async function (role) {
    // does an agent for this role already exist?
    const roleAgent = this.getAgentByRole(role);
    if (roleAgent) {
        this.setAgentByRole(role, roleAgent);
        return;
    }

    // construct and send a login request
    const agent = this.newAgent();
github open-draft / msw / spec / support / world.js View on Github external
return {
          headers,
          body: await res.json(),
        }
      },
      method,
      url,
    )

    // Store response for further assertions
    this.response = response
  }
}

setWorldConstructor(World)
github kozhevnikov / cucumber-pretty / test / features / support / hooks.js View on Github external
const { setWorldConstructor, BeforeAll, Before, After, AfterAll } = require('cucumber');

const World = require('./World');

setWorldConstructor(World);

if (process.argv.some((arg) => arg === 'test/features/hook.feature')) {
  BeforeAll(() => { console.log('BeforeAll'); });
  AfterAll(() => { console.log('AfterAll'); });
}

Before('@before', () => { console.log('Before'); });

After('@after', () => { console.log('After'); });
github kuzzleio / sdk-javascript / features / support / world.js View on Github external
this.jwt = null;
    this.rights = null;
    this.previousJwt = null;

    this.content = null;
    this.error = null;
    this.notifications = [];

    this.callback = notification => {
      this.notifications.push(notification);
    };
  }

}

setWorldConstructor(World);
github thetribeio / node-react-starter-kit / features / support / world.js View on Github external
import { setDefaultTimeout, setWorldConstructor } from 'cucumber';
import Factory from '../pages/Factory';

setDefaultTimeout(60 * 1000);

class World {
    constructor(args) {
        this.browser = args.parameters.browser;
        this.local = args.parameters.local;
        this.display = args.parameters.display;
        this.pageFactory = new Factory(this);
        this.host = 'http://app.local:3000';
    }
}

setWorldConstructor(World);

cucumber

The official JavaScript implementation of Cucumber.

MIT
Latest version published 3 years ago

Package Health Score

64 / 100
Full package analysis