This project was used by me (Gaston) while ramping-up on CodeceptJS. These are my notes, so no warranty is provided.
Goals:
- Quickly ramp-up on CodeceptJS
- Create a simple, yet useful test (i.e. log into Peregrine)
- Run tests locally
- Run tests on Docker
- Record test run
- Run tests on your machine.
$ ./local-run.sh
or
$ npm run test
- Build the Docker image (or pull it from DockerHub).
$ ./docker-build.sh
- Run the tests and capture video.
$ ./docker-run.sh
or
$ npm run docker-test
This project was bootstrapped using the following instructions.
- Create a workspace.
$ mkdir codeceptjs-explore && cd codeceptjs-explore
- Install CodeceptJS and Puppeteer.
$ npm init -y
$ npm install codeceptjs puppeteer --save-dev
- Create a CodeceptJS project.
$ npx codeceptjs init
All the defaults were used, except for these changes:
- What helpers do you want to use?: Puppeteer
- [Puppeteer] Base url of site to be tested: http://localhost:8080
- Feature which is being tested: Peregrine Login
-
Start Peregrine locally in another terminal.
-
Edit
login_test.js
.
Feature('login');
Scenario('Log into Peregrine', (I) => {
I.amOnPage('/');
I.see('Log In');
I.fillField('Username', 'admin');
I.fillField('Password', 'admin');
I.click('Log In');
I.see('your websites');
});
- To run tests on your machine with Docker, add
--no-sandbox
argument tocodecept.conf.js
. See issues/1022.
Puppeteer: {
...
chrome: {
...
args: ['--no-sandbox']
}
}