scipio-geppetto
v0.0.16
Published
slim wrapper around puppeteer and jest for e2e testing
Downloads
3
Readme
Geppetto @scipio/geppetto
Geppetto is nothing special. It is a simple facade infront of babel jest and puppeteer. It also makes for a convient dependency for a bunch or smaller packages commonly used in QA testing. It takes any babel and/or jest conguration files and adds a custom geppetto configuration to manage puppetere. It also combines commonly bundled puppetere calls into a simplified API while still exposing the raw puppetere browser and page objects.
Setup
Install packages
In the project root run:
npm i
Configuration
Configure Geppetto With Envronment Variables and or Configuration files
Environment Variables
| ENV name | required | default Value | | ----------------------- | --------------- | --------------------- | | GEP_CONFIG_PATH | no | | | GEP_COVERAGE | no | false | | GEP_TEST_TIMEOUT | no | 5000 | | GEP_VERBOSE | no | true | | GEP_HEADLESS | no | false | | GEP_SLO_MO | no | 10 | | GEP_BASE_URL | no | http://localhost:3015 |
Configuration files
There are several Configuration files that you can optionally override. Look at the configuration file before you override it cause there many Environment variables embedded inside of them.
geppetto.config.js
module.exports = {
browser: {
headless: process.env.GEP_HEADLESS !== undefined
? process.env.GEP_HEADLESS
: false,
slowMo: process.env.GEP_SLO_MO !== undefined
? process.env.GEP_SLO_MO
: 10,
devtools: false,
args: ['--disable-infobars', '--window-size=1200,900'],
defaultViewport: null,
},
baseURL: process.env.GEP_BASE_URL || "http://localhost:3015"
};
By default boon E2E Empty Project will have a geppetto.config.js file that point to this location
Any file that replaces this one will be the one used by Geppetto.
You can override geppetto.config.js by setting GEP_CONFIG_PATH environment variable to a relative path from current working dir
process.cmd()
module.exports = require('@boon/geppetto/geppetto.config.js')
jest.config.js
module.exports = {
collectCoverage: process.env.GEP_COVERAGE !== undefined
? process.env.GEP_COVERAGE
: false,
testMatch: [
"**/test/**/*.test.js",
"**/test/**/*.spec.js",
"**/e2e/**/*.test.js",
"**/e2e/**/*.spec.js"
],
testPathIgnorePatterns: ['node_modules', 'dist'],
testTimeout: process.env.GEP_TEST_TIMEOUT !== undefined
? process.env.GEP_TEST_TIMEOUT
: 5000,
verbose: process.env.GEP_VERBOSE !== undefined
? process.env.GEP_VERBOSE
: true
}
This is a stanard Jest config file Jest Configuratiopn
Any file that replaces this one will be the one used by Jest.
By default boon E2E Empty Project will have a jest.config.js file that point to this location
module.exports = require('@boon/geppetto/jest.config.js')
babel.config.js
module.exports = {
presets:[
["@babel/preset-env",{
targets: {
node:"current"
}
}]
]
}
This is a stanard Babel config file Babel Configuratiopn
Any file that replaces this one will be the one used by Jest.
default boon E2E Empty Project will have a babel.config.js file that point to this location
module.exports = require('@boon/geppetto/babel.config.js')
Publish geppetto
To publish a new version of geppetto, update package.json with the next version number and run:
npm run publish
Troubleshooting
> @scipio/[email protected] test
> jest --runInBand --detectOpenHandles
sh: jest: command not found
try to install jest globally.
npm i -g jest-cli