Test any website using Chrome Headless, Puppeteer, Mocha and Chai.
- Docker.
This example makes sure it is possible to perform a search on Google.com.
docker run --rm -v "$(pwd)"/example01/test:/app/test \
-v "$(pwd)"/artifacts:/artifacts \
dcycle/browsertesting:4
This second example builds a "to do" app in a Docker container, then runs tests against it.
cd ./example02 && ./build-sample-app.sh && cd ..
docker run --rm -v "$(pwd)"/example02/test:/app/test \
-v "$(pwd)"/artifacts:/artifacts \
--network myapp-network \
dcycle/browsertesting:4 test/test.js
docker run --rm -v "$(pwd)"/example01/failing-test-example:/app/test \
-v "$(pwd)"/artifacts:/artifacts \
dcycle/browsertesting:4
docker run --rm -v "$(pwd)"/example01/passing-test-example:/app/test \
-v "$(pwd)"/artifacts:/artifacts \
dcycle/browsertesting:4
docker run --rm -v "$(pwd)"/example01/selector-not-present-example:/app/test \
-v "$(pwd)"/artifacts:/artifacts \
dcycle/browsertesting:4
- Version 5 uses Chai 5 and introduces breaking changes from version 4 (see "Migrating from tag 4 to tag 5", below)
- Version 4 uses Chai 4 and is deprecated, so you are encouraged to migrate to tag 5 of this project.
- this.timeout(15000) throws error if we put it inside arrow function. Hence shouldn't use arrow in that context, Use function syntax as shown below example.
it('It should be possible to search for something on Google', async function() {
this.timeout(15000);
})
- Your test files should have the extension .mjs rather than .js
- Instead of
const { expect } = require('chai')
, useimport { expect } from 'chai';
- Follow es6 js coding standard in your code.. es6 features.
- See this pull request for an example of how to migrate your test files from tag 4 to 5