<titledata-rh="true">Contributing | Puppeteer</title><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"property="og:url"content="https://pptr.dev/next/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="/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://pptr.dev/next/contributing"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/contributing"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/contributing"hreflang="x-default"><linkrel="stylesheet"href="/assets/css/styles.39576fb3.css">
<divrole="region"><ahref="#"class="skipToContent_fXgn">Skip to main content</a></div><navclass="navbar navbar--fixed-top"><divclass="navbar__inner"><divclass="navbar__items"><buttonaria-label="Navigation bar toggle"class="navbar__toggle clean-btn"type="button"tabindex="0"><svgwidth="30"height="30"viewBox="0 0 30 30"aria-hidden="true"><pathstroke="currentColor"stroke-linecap="round"stroke-miterlimit="10"stroke-width="2"d="M4 7h22M4 15h22M4 23h22"></path></svg></button><aclass="navbar__brand"href="/"><divclass="navbar__logo"><imgsrc="https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png"alt="Puppeteer Logo"class="themedImage_ToTc themedImage--light_HNdA"><imgsrc="https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png"alt="Puppeteer Logo"class="themedImage_ToTc themedImage--dark_i4oU"></div><bclass="navbar__title text--truncate">Puppeteer</b></a></div><divclass="navbar__items navbar__items--right"><divclass="navbar__item dropdown dropdown--hoverable dropdown--right"><aaria-current="page"class="navbar__link active"aria-haspopup="true"aria-expanded="false"role="button"href="/next/">Next</a><ulclass="dropdown__menu"><li><aaria-current="page"class="dropdown__link dropdown__link--active"href="/next/contributing">Next</a></li><li><aclass="dropdown__link"href="/contributing">15.3.0</a></li></ul></div><divclass="searchBox_ZlJk"><divclass="navbar__search searchBarContainer_NW3z"><inputplaceholder="Search"aria-label="Search"class="navbar__search-input"><divclass="loadingRing_RJI3 searchBarLoadingRing_YnHq"><div></div><div></div><div></div><div></div></div><divclass="searchHintContainer_Pkmr"><kbdclass="searchHint_iIMx">ctrl</kbd><kbdclass="searchHint_iIMx">K</kbd></div></div></div><divclass="toggle_vylO colorModeToggle_DEke"><buttonclass="clean-btn toggleButton_gllP toggleButtonDisabled_aARS"type="button"disabled=""title="Switch between dark and light mode (currently light mode)"aria-label="Switch between dark and light mode (currently light mode)"><svgviewBox="0 0 24 24"width="24"height="24"class="lightToggleIcon_pyhR"><pathfill="currentColor"d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svgviewBox="0 0 24 24"width="24"height="24"class="darkToggleIcon_wfgR"><pathfill="currentColor"d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg></button></div></div></div><divrole="presentation"class="navbar-sidebar__backdrop"></div></nav><divclass="main-wrapper docsWrapper_BCFX"><buttonaria-label="Scroll back to top"class="clean-btn theme-back-to-top-button backToTopButton_sjWU"type="button"></button><divclass="docPage__5DB"><asideclass="theme-doc-sidebar-container docSidebarContainer_b6E3"><divclass="sidebar_njMd"><na
We'd love to accept your patches and contributions!</p><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 the 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><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token comment"style="color:#999988;font-style:italic"># Downloads the Firefox binary for Firefox tests</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token assign-left variable"style="color:#36acaa">PUPPETEER_PRODUCT</span><spanclass="token operator"style="color:#393A34">=</span><spanclass="token plain">firefox </span><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>Build and 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 build </span><spanclass="token operator"style="color:#393A34">&&</span><spanclass="token plain"></span><spanclass="token function"style="color:#d73a49">npm</span><spanclass="token plain"> run </span><spanclass="token builtin class-name">test</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><p>Our coding style is fully defined in
(<ahref="https://prettier.io"target="_blank"rel="noopener noreferrer">Prettier</a>).</p><p>Code is checked during <code>pre-push</code> using
<ahref="https://typicode.github.io/husky/#/"target="_blank"rel="noopener noreferrer">Husky</a>, but you can check your code
manually 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 lint</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>If some errors are returned, you can attempt to fix them using:</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 </span><spanclass="token function"style="color:#d73a49">format</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="project-structure">Project structure<aclass="hash-link"href="#project-structure"title="Direct link to heading"></a></h2><p>The following is a description of the primary folders in Puppeteer:</p><ul><li><code>src</code> - contains the source code for Puppeteer.</li><li><code>test/src</code> - contains the source code for Puppeteer tests.</li><li><code>utils</code>/<code>scripts</code> - contains various scripts.</li><li><code>utils/testserver</code> - contains the source code for our test servers in testing.</li><li><code>compat</code> - contains code separated by module import type. See <ahref="https://github.com/puppeteer/puppeteer/blob/main/compat/README.md"target="_blank"rel="noopener noreferrer"><code>compat/README.md</code></a> for details.</li><li><code>test-d</code> contains type tests using <ahref="https://github.com/SamVerschueren/tsd"target="_blank"rel="noopener noreferrer"><code>tsd</code></a>.</li><li><code>vendor</code> contains all dependencies that we vendor into the final build. See the <ahref="https://github.com/puppeteer/puppeteer/blob/main/vendor/README.md"target="_blank"rel="noopener noreferrer"><code>vendor/README.md</code></a> for details.</li></ul><h3class="anchor anchorWithStickyNavbar_LWe7"id="shipping-cjs-and-esm-bundles">Shipping CJS and ESM bundles<aclass="hash-link"href="#shipping-cjs-and-esm-bundles"title="Direct link to heading"></a></h3><p>Puppeteer ships both CommonJS and ES modules, therefore we maintain two <code>tsconfig</code> files for each project: <code>tsconfig.esm.json</code> and <code>tsconfig.cjs.json</code>. At build time we compile twice, once for CommonJS and once for ES modules.</p><p>We compile into the <code>lib</code> directory which is what we publish on the npm repository and it's structured like so:</p><divclass="codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#
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 check: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</code> and <code>npm install</code>.</li><li>Run <code>npm test</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">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="/next/troubleshooting"><divclass="pagination-nav__sublabel">Previous</div><divclass="pagination-nav__label">Troubleshooting</div></a><aclass="pagination-nav__link pagination-nav__link--next"href="/next/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="#project-structure"class="table-of-contents__link toc-highlight">Project structure</a><ul><li><ahref="#shipping-cjs-and-esm-bundles"class="table-of-contents__link toc-highlight">Shipping CJS and ESM bundles</a></li><li><ahref="#tsconfigjson-for-the-tests"class="table-of-contents__linktoc