ekino / veggies

:sparkles: :rocket: Veggies is an awesome cucumberjs library for API/CLI testing. Great for testing APIs built upon Express, Koa, HAPI, Loopback and others. It's also the perfect companion for testing CLI applications built with commander, meow & Co.
https://ekino.github.io/veggies/
MIT License
90 stars 18 forks source link

Not using defineSupportCode in installation examples anymore #35

Closed lelbil closed 3 years ago

lelbil commented 6 years ago

Do you want to request a feature or report a bug? More of a Readme update.

What is the current behavior? The readme has some installation examples, they all have defineSupportCode, a function that was deprecated in cucumber in version 4.0.0 (Cucumber Changelog)

If the current behavior is a bug, please provide the steps to reproduce. When running tests with a cucumber >= 4.0.0, we get a warning message: DeprecationWarning: cucumber: defineSupportCode is deprecated. Please require/import the individual methods instead.

What is the expected behavior? Rewrite the readme installation examples without using the deprecated method.

An example might be:

const { setWorldConstructor, Given, Then, When, Before } = require('cucumber')
const { state, fixtures, httpApi, cli } = require('@ekino/veggies')
const fixturesHooks = require('@ekino/veggies/src/extensions/fixtures/hooks')
const stateDefinitions = require('@ekino/veggies/src/extensions/state/definitions')
const httpApiDefinitions = require('@ekino/veggies/src/extensions/http_api/definitions')
const cliDefinitions = require('@ekino/veggies/src/extensions/cli/definitions')

setWorldConstructor(function() {
    state.extendWorld(this)
    fixtures.extendWorld(this)
    httpApi.extendWorld(this)
    cli.extendWorld(this)
})

stateDefinitions({Given, When})
fixturesHooks({Before})
httpApiDefinitions({ baseUrl: 'http://localhost:3000' })({Given, Then, When})
cliDefinitions({Given, Then, When})

Also, the required parts of veggies (i.e the definitions for each extension, the hooks for fixtures or the step definitions.. for example) can be exposed through the extension itself to have less requires and be able to use them directly like this: state.defintions({Given, When})

What do you think?

Please provide your exact configuration and mention your veggies, node, yarn/npm version and operating system. I am using an official node image with latest tag OS: Linux Node: v10.6.0 NPM: 6.1.0 Veggies: 0.6.0 Cucumber: 5.0.1

leguellec commented 3 years ago

Resolved by #36