Cucumber-mink

Quick and easy testing with cucumber.js

NPM Version Build Status Test Coverage JS.ORG

What is Cucumber-mink ?

Cucumber-mink lets you write Gherkin BDD style end-to-end test and run it inside any browser. You don't have to do any complex configuration, just focus on writing test:

Feature: Post page

  Background:
    Given I browse "http://my-app:3000/"

  Scenario: Go on post 1
    Given I am on homepage
    And I follow "Post-1"
    Then I should be on "/post/1"
    And I should see "Post-1"

What steps can I use ?

Cucumber mink comes with 40+ built-in steps, those provides the essential set to test your website.
See the available steps

Can I extend it ?

Yes, you can define your own custom steps just like in standard Cucumber.js.
A set of useful methods are also available with mink: Core API

Running your test suite

In order to run ours test suite, we need a Selenium server (headless browser).
I'll use Firefox with default selenium settings: localhost:4444 through Protractor's webdriver-manager

With the CLI

$ webdriver-manager start &
$ cucumber-mink features/test.feature -- -f pretty

Feature: Post page

  Scenario: Go on post 1                                      # features/test.feature:4
    Given I browse "http://my-app:3000/"                      # features/test.feature:7
    Given I am on homepage                                    # features/test.feature:8
    And I follow "Post-1"                                     # features/test.feature:9
    Then I should be on "/post/1"                             # features/test.feature:10
    And I should see "Post-1"                                 # features/test.feature:11

See cucumber-mink -h if you want to use the CLI with a custom Selenium server

With Cucumber.js support code

// features/support/mink.js

const Mink = require('cucumber-mink');

// Selenium + Firefox
const parameters = {
  driver: {
    logLevel: 'silent',
    desiredCapabilities: {
      browserName: 'firefox',
    },
    port: 4444,
  },
  timeout: 5000,
};

module.exports = function () {
  Mink.init(this, parameters);
};

See examples for support code method with BrowserStack, SauceLabs, Chrome and Firefox

How does it work?

Cucumber-mink is an open source addon for cucumber.js. It makes it possible to quickly write Gherkin tests with Cucumber.js framework.

It use WebdriverIO internally to send request to the Selenium server.

Run your tests in the cloud

Services like Sauce Labs or BrowserStack provide selenium testing on remote hosts. You're able to run tests on a wide collection of platforms, devices and browser combinations.

Sauce Labs BrowserStack TestingBot