<titledata-rh="true">Contributing | Puppeteer</title><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"property="og:url"content="https://puppeteer.github.io/puppeteer/contributing"><metadata-rh="true"name="docusaurus_locale"content="en"><metadata-rh="true"name="docsearch:language"content="en"><metadata-rh="true"name="docusaurus_version"content="current"><metadata-rh="true"name="docusaurus_tag"content="docs-default-current"><metadata-rh="true"name="docsearch:version"content="current"><metadata-rh="true"name="docsearch:docusaurus_tag"content="docs-default-current"><metadata-rh="true"property="og:title"content="Contributing | Puppeteer"><metadata-rh="true"name="description"content="First of all, thank you for your interest in Puppeteer!"><metadata-rh="true"property="og:description"content="First of all, thank you for your interest in Puppeteer!"><linkdata-rh="true"rel="icon"href="/puppeteer/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://puppeteer.github.io/puppeteer/contributing"><linkdata-rh="true"rel="alternate"href="https://puppeteer.github.io/puppeteer/contributing"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://puppeteer.github.io/puppeteer/contributing"hreflang="x-default"><linkrel="stylesheet"href="/puppeteer/assets/css/styles.d5636e50.css">
We'd love to accept your patches and contributions!</p><ul><li><ahref="#contributor-license-agreement">Contributor License Agreement</a></li><li><ahref="#getting-code">Getting Code</a></li><li><ahref="#code-reviews">Code reviews</a></li><li><ahref="#code-style">Code Style</a></li><li><ahref="#typescript-guidelines">TypeScript guidelines</a></li><li><ahref="#project-structure-and-typescript-compilation">Project structure and TypeScript compilation</a><ul><li><ahref="#shipping-cjs-and-esm-bundles">Shipping CJS and ESM bundles</a></li><li><ahref="#tsconfig-for-the-tests">tsconfig for the tests</a></li><li><ahref="#root-tsconfigjson">Root <code>tsconfig.json</code></a></li></ul></li><li><ahref="#api-guidelines">API guidelines</a></li><li><ahref="#commit-messages">Commit Messages</a></li><li><ahref="#writing-documentation">Writing Documentation</a></li><li><ahref="#writing-tsdoc-comments">Writing TSDoc Comments</a></li><li><ahref="#running-new-documentation-website-locally">Running New Documentation website locally</a></li><li><ahref="#adding-new-dependencies">Adding New Dependencies</a></li><li><ahref="#running--writing-tests">Running & Writing Tests</a></li><li><ahref="#public-api-coverage">Public API Coverage</a></li><li><ahref="#debugging-puppeteer">Debugging Puppeteer</a>
undefined <ahref="#for-project-maintainers">For Project Maintainers</a></li><li><ahref="#rolling-new-chromium-version">Rolling new Chromium version</a><ul><li><ahref="#bisecting-upstream-changes">Bisecting upstream changes</a></li></ul></li><li><ahref="#releasing-to-npm">Releasing to npm</a></li></ul><h2class="anchor anchorWithStickyNavbar_LWe7"id="contributor-license-agreement">Contributor License Agreement<aclass="hash-link"href="#contributor-license-agreement"title="Direct link to heading"></a></h2><p>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 <ahref="https://cla.developers.google.com/"target="_blank"rel="noopener noreferrer">https://cla.developers.google.com/</a> to see
your current agreements on file or to sign a new one.</p><p>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.</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="getting-code">Getting Code<aclass="hash-link"href="#getting-code"title="Direct link to heading"></a></h2><ol><li>Clone this repository</li></ol><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token function"style="color:#d73a49">git</span><spanclass="token plain"> clone https://github.com/puppeteer/puppeteer</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token builtin class-name">cd</span><spanclass="token plain"> puppeteer</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgclass="copyButtonIcon_y97N"viewBox="0 0 24 24"><pathd="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgclass="copyButtonSuccessIcon_LjdS"viewBox="0 0 24 24"><pathd="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><olstart="2"><li>Install dependencies</li></ol><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token function"style="color:#d73a49">npm</span><spanclass="token plain"></span><spanclass="token function"style="color:#d73a49">install</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgclass="copyButtonIcon_y97N"viewBox="0 0 24 24"><pathd="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgclass="copyButtonSuccessIcon_LjdS"viewBox="0 0 24 24"><pathd="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><olstart="3"><li>Run Puppeteer tests locally. For more information about tests, read <ahref="#running--writing-tests">Running & Writing Tests</a>.</li></ol><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token function"style="color:#d73a49">npm</span><spanclass="token plain"> run test:unit</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgclass="copyButtonIcon_y97N"viewBox="0 0 24 24"><pathd="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgclass="copyButtonSuccessIcon_LjdS"viewBox="0 0 24 24"><pathd="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2class="anchor anchorWithStickyNavbar_LWe7"id="code-reviews">Code reviews<aclass="hash-link"href="#code-reviews"title="Direct link to heading"></a></h2><p>All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
<ahref="https://help.github.com/articles/about-pull-requests/"target="_blank"rel="noopener noreferrer">GitHub Help</a> for more
information on using pull requests.</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="code-style">Code Style<aclass="hash-link"href="#code-style"title="Direct link to heading"></a></h2><ul><li>Coding style is fully defined in <ahref="https://github.com/puppeteer/puppeteer/blob/main/.eslintrc.js"target="_blank"rel="noopener noreferrer"><code>.eslintrc</code></a> and we automatically format our code with <ahref="https://prettier.io"target="_blank"rel="noopener noreferrer">Prettier</a>.</li><li>It's recommended to set-up Prettier into your editor, or you can run <code>npm run lint:eslint:fix</code> to automatically format any files.</li><li>If you're working in a JS file, code should be annotated with <ahref="https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler"target="_blank"rel="noopener noreferrer">closure annotations</a>.</li><li>If you're working in a TS file, you should explicitly type all variables and return types. You'll get ESLint warnings if you don't so if you're not sure use them as guidelines, and feel free to ask us for help!</li></ul><p>To run ESLint, use:</p><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token function"style="color:#d73a49">npm</span><spanclass="token plain"> run lint:eslint</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgclass="copyButtonIcon_y97N"viewBox="0 0 24 24"><pathd="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgclass="copyButtonSuccessIcon_LjdS"viewBox="0 0 24 24"><pathd="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>You can check your code by running:</p><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token function"style="color:#d73a49">npm</span><spanclass="token plain"> run build</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgclass="copyButtonIcon_y97N"viewBox="0 0 24 24"><pathd="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgclass="copyButtonSuccessIcon_LjdS"viewBox="0 0 24 24"><pathd="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2class="anchor anchorWithStickyNavbar_LWe7"id="typescript-guidelines">TypeScript guidelines<aclass="hash-link"href="#typescript-guidelines"title="Direct link to heading"></a></h2><ul><li>Try to avoid the use of <code>any</code> when possible. Consider <code>unknown</code> as a better alternative. You are able to use <code>any</code> if needbe, but it will generate an ESLint warning.</li></ul><h2class="anchor anchorWithStickyNavbar_LWe7"id="project-structure-and-typescript-compilation">Project structure and TypeScript compilation<aclass="hash-link"href="#project-structure-and-typescript-compilation"title="Direct link to heading"></a></h2><p>The code in Puppeteer is split primarily into two folders:</p><ul><li><code>src</code> contains all source code</li><li><code>vendor</code> contains all dependencies that we've vendored into the
Not all revisions have builds for all platforms, so we need to find one that does.
To do so, run <code>utils/check_availability.js -rd</code> to find the latest suitable <code>dev</code> Chromium revision (see <code>utils/check_availability.js -help</code> for more options).</li><li>Update <code>src/revisions.ts</code> with the found revision number.</li><li>Update <code>versions.js</code> with the new Chromium-to-Puppeteer version mapping and update <code>lastMaintainedChromiumVersion</code> with the latest stable Chrome version.</li><li>Run <code>npm run test:protocol-revision</code>.
If it fails, update <code>package.json</code> with the expected <code>devtools-protocol</code> version.</li><li>Run <code>npm run build:tsc</code> and <code>npm install</code>.</li><li>Run <code>npm run test:unit</code> and ensure that all tests pass. If a test fails, <ahref="#bisecting-upstream-changes">bisect</a> the upstream cause of the failure, and either update the test expectations accordingly (if it was an intended change) or work around the changes in Puppeteer (if it’s not desirable to change Puppeteer’s observable behavior).</li><li>Commit and push your changes and open a pull request.
The commit message must contain the version in <code>Chromium <version> (<revision>)</code> format to ensure that <ahref="https://pptr.dev/"target="_blank"rel="noopener noreferrer">pptr.dev</a> can parse it correctly, e.g. <code>'feat(chromium): roll to Chromium 90.0.4427.0 (r856583)'</code>.</li></ol><h3class="anchor anchorWithStickyNavbar_LWe7"id="bisecting-upstream-changes">Bisecting upstream changes<aclass="hash-link"href="#bisecting-upstream-changes"title="Direct link to heading"></a></h3><p>Sometimes, performing a Chromium roll causes tests to fail. To figure out the cause, you need to bisect Chromium revisions to figure out the earliest possible revision that changed the behavior. The script in <code>utils/bisect.js</code> can be helpful here. Given a pattern for one or more unit tests, it will automatically bisect the current range:</p><divclass="language-sh codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-sh codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token plain">node utils/bisect.js --good 686378 --bad 706915 script.js</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">node utils/bisect.js --unit-test Response.fromCache</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgclass="copyButtonIcon_y97N"viewBox="0 0 24 24"><pathd="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgclass="copyButtonSuccessIcon_LjdS"viewBox="0 0 24 24"><pathd="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>By default, it will use the Chromium revision in <code>src/revisions.ts</code> from the <code>main</code> branch and from the working tree to determine the range to bisect.</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="releasing-to-npm">Releasing to npm<aclass="hash-link"href="#releasing-to-npm"title="Direct link to heading"></a></h2><p>We use <ahref="https://github.com/googleapis/release-please"target="_blank"rel="noopener noreferrer">release-please</a> to automate releases. When a release should be done, check for the release PR in our <ahref="https://github.com/puppeteer/puppeteer/pulls"target="_blank"rel="noopener noreferrer">pull requests</a> and merge it.</p></div></article><navclass="pagination-nav docusaurus-mt-lg"aria-label="Docs pages navigation"><aclass="pagination-nav__link pagination-nav__link--prev"href="/puppeteer/troubleshooting"><divclass="pagination-nav__sublabel">Previous</div><divclass="pagination-nav__label">Troubleshooting</div></a><aclass="pagination-nav__link pagination-nav__link--next"href="/puppeteer/chromium-support"><divclass="pagination-nav__sublabel">Next</div><divclass="pagination-nav__label">Chromium Support</div></a></nav></div></div><divclass="col col--3"><divclass="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ulclass="table-of-contents table-of-contents__left-border"><li><ahref="#contributor-license-agreement"class="table-of-contents__link toc-highlight">Contributor License Agreement</a></li><li><ahref="#getting-code"class="table-of-contents__link toc-highlight">Getting Code</a></li><li><ahref="#code-reviews"class="table-of-contents__link toc-highlight">Code reviews</a></li><li><ahref="#code-style"class="table-of-contents__link toc-highlight">Code Style</a></li><li><ahref="#typescript-guidelines"class="table-of-contents__link toc-highlight">TypeScript guidelines</a></li><li><ahref="#project-structure-and-typescript-compilation"clas