First of all, thank you for your interest in Puppeteer! We'd love to accept your patches and contributions!
Contributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution, this simply gives us permission to use and redistribute your contributions as part of the project. Head over to https://cla.developers.google.com/ to see your current agreements on file or to sign a new one.
You generally only need to submit a CLA once, so if you‘ve already submitted one (even if it was for a different project), you probably don’t need to do it again.
git clone https://github.com/GoogleChrome/puppeteer cd puppeteer
npm install
npm run unit
All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.
To run code linter, use:
npm run lint
When authoring new API methods, consider the following:
page.keyboard
and page.coverage
Commit messages should follow the Semantic Commit Messages format:
label(namespace): title description footer
fix
- puppeteer bug fixes.feat
- puppeteer features.docs
- changes to docs, e.g. docs(api.md): ..
to change documentation.test
- changes to puppeteer tests infrastructure.style
- puppeteer code style: spaces/alignment/wrapping etc.chore
- build-related work, e.g. doclint changes / travis / appveyor.Example:
fix(page): fix page.pizza method This patch fixes page.pizza so that it works with iframes. Fixes #123, Fixes #234 BREAKING CHANGE: page.pizza now delivers pizza at home by default. To deliver to a different location, use "deliver" option: `page.pizza({deliver: 'work'})`.
All public API should have a descriptive entry in docs/api.md
. There's a documentation linter which makes sure documentation is aligned with the codebase.
To run the documentation linter, use:
npm run doc
For all dependencies (both installation and development):
A barrier for introducing new installation dependencies is especially high:
Puppeteer tests are located in test/test.js
and are written with a TestRunner framework. Despite being named ‘unit’, these are integration tests, making sure public API methods and events work as expected.
npm run unit
-j
flag:npm run unit -- -j 4
npm run unit -- --verbose npm run unit -- --break-on-failure
it
with fit
(mnemonic rule: ‘focus it’):... // Using "fit" to run specific test fit('should work', async function({server, page}) { const response = await page.goto(server.EMPTY_PAGE); expect(response.ok).toBe(true); });
it
with xit
(mnemonic rule: ‘cross it’):... // Using "xit" to skip specific test xit('should work', async function({server, page}) { const response = await page.goto(server.EMPTY_PAGE); expect(response.ok).toBe(true); });
HEADLESS=false npm run unit
CHROME=<path-to-executable> npm run unit
HEADLESS=false SLOW_MO=500 npm run unit
node --inspect-brk test/test.js
Every public API method or event should be called at least once in tests. To ensure this, there's a coverage
command which tracks calls to public API and reports back if some methods/events were not called.
Run coverage:
npm run coverage
See Debugging Tips in the readme.
Releasing to npm consists of the following phases:
package.json
version following the SEMVER rules, run npm run doc
to update the docs accordingly, and send a PR titled 'chore: mark version vXXX.YYY.ZZZ'
(example).'v'
, e.g. for version 1.4.0
the tag is v1.4.0
.git log --pretty="%h - %s" v1.19.0..HEAD
.docs/api.md
to include the new version.puppeteer
to npm.git status
and make sure there are no untracked files.npx pkgfiles
to make sure you don't publish anything unnecessary.npm publish
. This publishes the puppeteer
package.puppeteer-core
to npm../utils/prepare_puppeteer_core.js
. The script changes the name inside package.json
to puppeteer-core
.npm publish
. This publishes the puppeteer-core
package.git reset --hard
to reset the changes to package.json
.package.json
version to -post
version and send a PR titled 'chore: bump version to vXXX.YYY.ZZZ-post'
(example)docs/api.md
by running npm run doc
.For both puppeteer
and puppeteer-core
we maintain the following npm tags:
chrome-*
tags, e.g. chrome-75
and so on. These tags match the Puppeteer version that corresponds to the chrome-*
release.chrome-stable
tag. This tag points to the Puppeteer version that works with the current Chrome stable release.These tags are updated on every Puppeteer release.
NOTE: due to Chrome's rolling release, we take omahaproxy's linux stable version as stable.
Managing tags 101:
# list tags $ npm dist-tag ls puppeteer # Removing a tag $ npm dist-tag rm puppeteer-core chrome-stable # Adding a tag $ npm dist-tag add puppeteer-core@1.13.0 chrome-stable