Run testcafe tests with gherkin syntax based on sitegist's gherkin-testcafe (on npmjs.com)
Albino Cordeiro albino.cordeirojr@gemalto.com
Currently, this tool is still under development and very likely present bugs and doesn't support some features supported by cucumberjs, etc
Uses TestCafe as testrunner, avoiding dependency on cucumberjs. Support more modern javascript syntax (very close to Typescript). Modify some behaviors of gherkin-testcafe that seemed wrong to me.
npm install --save-dev gherkcafe
Take a look at the examples/
folder in this repo, to get an idea of how to write gherkin specs and step definitions.
Example:
gherkin-testcafe --specs ./tests/**/*.feature --steps ./tests/**/*.js --browsers chrome
--specs [list of file patterns]
- One or more paths or glob patterns to the *.feature
files to be tested.
--steps [list of file patterns]
- One or more paths or glob patterns to the *.js
files containing the step definitions.
--browsers
- A space-separated list of browsers to run the tests in (see Testcafe Browser Support)
--ports
- Up to 2 ports that will be used by testcafe to serve tested webpages
With the --steps
parameter you can specify where to find your step definitions. These are contained in a file of the following form:
module.exports = function defineSteps({given, when, then}) {
given(`I have a step definition with parameter {string}`, async (t, myParameter) => {
// Test implementation here
});
}
given
, when
and then
refer to their gherkin counterparts. Each of these functions takes two parameters.
The first one expects a parameterized step expression. You'll find more on that in the cucumber-expressions Documentation.
The second one expects a function (that is allowed to be be async
), which executes the actual test. That function
will get the testcafe test controller as its first parameter (t
in the example). With that you can use the entirety
of test cafes Test API.
All subsequent parameters for the test function are resolved from the given step expression.
see LICENSE.md