GithubHelp home page GithubHelp logo

rommmy / gherkin-testcafe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arthy000/gherkin-testcafe

1.0 1.0 0.0 30 KB

Run testcafe tests with gherkin syntax

License: MIT License

Shell 3.21% JavaScript 96.79%

gherkin-testcafe's Introduction

gherkin-testcafe

Run testcafe tests with gherkin syntax

Authors & Sponsors

The development and the public-releases of this package is generously sponsored by our employer http://www.sitegeist.de.

This package is inspired by helen-dikareva/testcafe-cucumber-demo. The test example for the google search is taken from there.

Support

Currently, this tool is still under development and very likely to break.

Why?

DevExpress' testcafe is an amazing tool for writing acceptance tests. Unfortunately it currently lacks support for BDD-style tests using the famous gherkin Syntax (Although there seem to be plans for future support).

This tool provides a setup in which gherkin *.feature specs can be used to run testcafe tests.

What does this do?

The tool itself has just a small footprint to glue testcafe and gherkin together.

It uses testcafe as the testrunner and constructs the fixture and test calls from gherkin sources during runtime.

To interpret *.feature files written in gherkin, it uses the gherkin package from npm. To allow custom step definitions it uses the cucumber-expressions package from npm. Both of those packages are provided by the cucumber project.

Installation

With npm:

npm install --save-dev gherkin-testcafe

With yarn:

yarn add --dev gherkin-testcafe

Usage with CLI

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 --browers chromium firefox

Supported Parameters

--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

Usage with docker

  1. Start up the container for the test runner
docker run --name testrunner -v $(pwd)/specs:/test/specs sitegeist/gherkin-testcafe
  1. Execute the tests
docker exec testrunner gherkin-testcafe --specs ./specs/**/*.feature --steps ./specs/**/*.js --browsers firefox
  1. Clean up
docker kill testrunner
docker rm testrunner

All parameters of the command line interface can be used, but the the list of browsers is limited to:

  • firefox
  • "chromium --no-sandbox"

Writing step definitions

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}`, (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.

License

see LICENSE.md

gherkin-testcafe's People

Contributors

grebaldi avatar rommmy avatar

Stargazers

Stanislas Bernard avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.