Skip to content

Running Tests

rquellh edited this page May 16, 2018 · 5 revisions

Disclaimer: The following page was tested using Windows. There will probably need some configuration changes for Mac and Linux. Most changes can be resolved by changing the package.json file.

Simple Command

When creating this repo, I wanted to make it easy to run tests using a simple command line command. You can run cucumber by executing the following command

.\node_modules\.bin\cucumber-js.cmd

but using the repos package.json file you could also execute

npm run test

Changing browsers

I've added the ability to change browsers in this repo as well. If a default browser is not specified, chrome will be browser that runs. You could run a new browser with the command

./node_modules/.bin/cucumber-js.cmd  --world-parameters '{\"browser\": \"firefox\"}'

or the package.json file has scripts you can execute

npm run test-chrome
npm run test-ie
npm run test-edge
npm run test-firefox
npm run test-opera
npm run test-safari

Running reports

If you want to run a JSON Cucumber report you can use the following command

./node_modules/.bin/cucumber-js.cmd --format json:./reports/report.json

or you can use the built in scripts

npm run test-report

Running different browsers and reports

If you want to run a JSON Cucumber report and specify the the browser you can use the following command

./node_modules/.bin/cucumber-js.cmd  --format json:./reports/report.json --world-parameters '{\"browser\": \"edge\"}'

or if you use the built in scripts

npm run test-chrome-report
npm run test-ie-report
npm run test-edge-report
npm run test-firefox-report
npm run test-opera-report
npm run test-safari-report

More Command Line commands

https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md