The METexpress tests are Cucumber and Webdriver-based acceptance tests. Access to certain data in the METexpress team's database is required.
We've found nvm is useful to manage node versions. Instructions on how to install node via NVM can be found here: https://github.com/nvm-sh/nvm#install--update-script. Once NVM is installed you can install the desired version of Node (we usually use the latest or match the version required by the version of Meteor we're on) and the dependencies required to run the tests by doing:
nvm install && npm install
The default test configuration is in the wdio.conf.js
file. Currently, the tests are configured to run 'maxInstances
' Chrome instances. There are options to run with regular Chrome or headless Chrome. We'd recommend headless Chrome so the test suite doesn't take over your laptop's desktop.
You can run tests via npm
by calling the scripts in package.json
like so:
npm run test
npm run test:headless
npm run test:debug
npm run test:debug:headless
You can pass flags like so:
npm run test -- --baseUrl 'https://esrl.noaa.gov/gsd/int-mats'
Otherwise, there are also some shell scripts in the METexpress/tests
directory that offer an easy start to running the test suite.
The METexpress/tests/src
directory structure is from the webdriver.io cucumber boilerplate project because that is what was used to make the tests run, their directory structure is easy to navigate.
Their predefined step definitions are left intact so that they can be used in the future, or at least used for reference.
This is where all the feature files are, much like the old features directories except I left out the load and performance subdirectories - which we weren't using anyway.
Has given.js
, then.js
, and when.js
. These have our cucumber step mappings, and they have the standard boilerplate ones as well - again mostly for reference.
This has action/
, check/
, and lib/
subdirs and this holds all the step definition files. We have definitions that match our tests as well as the standard boilerplate ones.
There could be a webdriver memory leak or maybe our tests are just "hoggy", but we had to increase the node memory allocation to keep from occasionally getting weird javascript errors. You do that by executing this command:
export NODE_OPTIONS="--max-old-space-size=8192"
inside your terminal prior to running the tests or by prefixing the below commands with the following
env NODE_OPTIONS="--max-old-space-size=8192" <npx command here>
This is taken care of in the npm run
commands and in the shell scripts.
npx wdio run wdio.conf.js
It will run 3 instances and it will test against METexpress internal dev server.
npx wdio run wdio.conf.js --baseUrl 'https://esrl.noaa.gov/gsd/int-mats'
npx wdio run wdio.conf.js --baseUrl 'https://esrl.noaa.gov/gsd/int-mats' --maxInstances 2
Note this is a relative path - you need to be in the METexpress/tests
directory
npx wdio run wdio.conf.js \
--baseUrl 'https://esrl.noaa.gov/gsd/int-mats' \
--spec ./src/features/met-airquality/basic/addRemoveContour.feature
By default the wdio.conf.js
specifies the spec reporter. We can also specify a reporter like below which would run the default dot reporter. Any of the supported reporters can be specified in this manner.
npx wdio run wdio.conf.js \
--reporters dot
You can have WebdriverIO watch your spec files and run them as they change by doing:
npx wdio run wdio.conf.js --watch