Sample code used for evaluating JavaScript testing frameworks:
-
A consistent baseline configuration for each framework:
-
Integration with common test-related services:
# Clone repo
git clone https://github.com/jhildenbiddle/ci-test.git
# Change to cloned repo directory
cd ci-test
# Install dependencies
npm install
# Run local tests
npm run test:cafe
npm run test:jest
npm run test:karma
npm run test:karma-debug
# Run remote tests (see "Notes" below)
npm run test:cafe-remote
npm run test:karma-remote
-
Node 8 (or 7.6 + polyfill) required
The sample code uses JavaScript's new async / await feature which requires Node 7.6 or above. The code also makes use of the util.promisify() utility function introduced in Node 8.x, but a polyfill is available for older versions.
-
Install Chrome 59+ for "headless" browser testing
Local tests are configured to use Chrome in "headless" mode by default. This requires Chrome 59 or above. If you do not have Chrome 59 (or above) installed or prefer to test with different browers, the settings for each test framework will need to be updated:
- Jest: No browers to specify (test are executed using jsdom)
- Karma: edit
karma.conf.js
and install the appropriate karma launchers - TestCafé: edit
package.json
and specify browsers via command line args
-
Set SauceLabs username and access key for remote testing
These can be set as environment variables (see SauceLabs wiki for details) or in
saucelabs.config.js
.