dollarshaveclub / e2e

Make End-to-End Testing Great For Once
MIT License
32 stars 3 forks source link

@dollarshaveclub/e2e

CircleCI codecov Greenkeeper badge

A end-to-end test runner currently built for:

This test runner mitigates test flakiness and maximizes test speed:

It also has features to make writing and running tests easier:

See our example tests.

Installation

Install Selenium:

brew tap homebrew/cask
brew cask install chromedriver
brew install selenium-server-standalone geckodriver

Start the Selenium server:

brew services start selenium-server-standalone

Install node@8+:

nvm install 8

API

Running Tests

Install this package:

npm install @dollarshaveclub/e2e

Run the executable:

./node_modules/.bin/dsc-e2e -h

Tests

You can define multiple clients and multiple parameters per test. If you have 5 clients and 5 parameters, your tests will run 5x5 = 25 times. Keep this in mind as you add clients and parameters.

exports.options\<Object>

Options for running the test.

Options are:

exports.parameters\<Object|Array>

Various parameters to run your test. Passed to your .test function and is intended to be used within it. If your parameters is an array, your test will run for each value in the array.

exports.test\({ step, parameters, ... })

Define your actual test in this function.

Selenium Options
Puppeteer Options

step(name\, fn\, options\)

A step in your test. Think of this as a test() or it() from mocha or jest. As this runner is designed for end-to-end tests, calling each code block steps makes more sense than calling it test() or it(). Unlike other frameworks, there is no nesting of step()s.

For example, if are testing the end-to-end flow of a conversion funnel, each action a user takes would be a step. Practically, however, you should write each await within its own step. The reason is many awaits wait for a condition to occur, and the only way to test that it does not occur is to timeout.

Thus, the options for each step are:

  • timeout - the timeout for this step
  • slowThreshold - when this step is considered slow

step.skip()

Same as step(), but is not actually ran.

exports.description<Function|String>

Description of your test.