puppeteer/contributing/index.html

32 lines
56 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-contributing">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.0-beta.21">
<title data-rh="true">Contributing | Puppeteer</title><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://puppeteer.github.io/puppeteer/contributing"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Contributing | Puppeteer"><meta data-rh="true" name="description" content="First of all, thank you for your interest in Puppeteer!"><meta data-rh="true" property="og:description" content="First of all, thank you for your interest in Puppeteer!"><link data-rh="true" rel="icon" href="/puppeteer/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://puppeteer.github.io/puppeteer/contributing"><link data-rh="true" rel="alternate" href="https://puppeteer.github.io/puppeteer/contributing" hreflang="en"><link data-rh="true" rel="alternate" href="https://puppeteer.github.io/puppeteer/contributing" hreflang="x-default"><link rel="stylesheet" href="/puppeteer/assets/css/styles.d5636e50.css">
<link rel="preload" href="/puppeteer/assets/js/runtime~main.e41f0c35.js" as="script">
<link rel="preload" href="/puppeteer/assets/js/main.8e9e8b27.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div role="region"><a href="#" class="skipToContent_fXgn">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/puppeteer/"><div class="navbar__logo"><img src="https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png" alt="Puppeteer Logo" class="themedImage_ToTc themedImage--light_HNdA"><img src="https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png" alt="Puppeteer Logo" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">Puppeteer</b></a></div><div class="navbar__items navbar__items--right"><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/puppeteer/">Next</a><div class="toggle_vylO colorModeToggle_DEke"><button class="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)"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_pyhR"><path fill="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><svg viewBox="0 0 24 24" width="24" height="24" class="darkToggleIcon_wfgR"><path fill="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 class="searchBox_ZlJk"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div class="main-wrapper docsWrapper_BCFX"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebar_njMd"><nav class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/puppeteer/">Puppeteer</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/puppeteer/faq">FAQ</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/puppeteer/troubleshooting">Troubleshooting</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" href="/puppeteer/contributing">Contributing</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/puppeteer/chromium-support">Chromium Support</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" href="/puppeteer/api/">API</a><button aria-label="Toggle the collapsible sidebar category &#x27;API&#x27;" type="button" class="clean-btn menu__caret"></button></div></li></ul></nav></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_GujU"><div class="docItemContainer_Adtb"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/puppeteer/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_OVgt"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Contributing</span><meta itemprop="position" content="1"></li></ul></nav><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_aoJ5"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><h1>Contributing</h1><p>First of all, thank you for your interest in Puppeteer!
We&#x27;d love to accept your patches and contributions!</p><ul><li><a href="#contributor-license-agreement">Contributor License Agreement</a></li><li><a href="#getting-code">Getting Code</a></li><li><a href="#code-reviews">Code reviews</a></li><li><a href="#code-style">Code Style</a></li><li><a href="#typescript-guidelines">TypeScript guidelines</a></li><li><a href="#project-structure-and-typescript-compilation">Project structure and TypeScript compilation</a><ul><li><a href="#shipping-cjs-and-esm-bundles">Shipping CJS and ESM bundles</a></li><li><a href="#tsconfig-for-the-tests">tsconfig for the tests</a></li><li><a href="#root-tsconfigjson">Root <code>tsconfig.json</code></a></li></ul></li><li><a href="#api-guidelines">API guidelines</a></li><li><a href="#commit-messages">Commit Messages</a></li><li><a href="#writing-documentation">Writing Documentation</a></li><li><a href="#writing-tsdoc-comments">Writing TSDoc Comments</a></li><li><a href="#running-new-documentation-website-locally">Running New Documentation website locally</a></li><li><a href="#adding-new-dependencies">Adding New Dependencies</a></li><li><a href="#running--writing-tests">Running &amp; Writing Tests</a></li><li><a href="#public-api-coverage">Public API Coverage</a></li><li><a href="#debugging-puppeteer">Debugging Puppeteer</a>
undefined <a href="#for-project-maintainers">For Project Maintainers</a></li><li><a href="#rolling-new-chromium-version">Rolling new Chromium version</a><ul><li><a href="#bisecting-upstream-changes">Bisecting upstream changes</a></li></ul></li><li><a href="#releasing-to-npm">Releasing to npm</a></li></ul><h2 class="anchor anchorWithStickyNavbar_LWe7" id="contributor-license-agreement">Contributor License Agreement<a class="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 <a href="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&#x27;ve already submitted one
(even if it was for a different project), you probably don&#x27;t need to do it
again.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="getting-code">Getting Code<a class="hash-link" href="#getting-code" title="Direct link to heading"></a></h2><ol><li>Clone this repository</li></ol><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">git</span><span class="token plain"> clone https://github.com/puppeteer/puppeteer</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token builtin class-name">cd</span><span class="token plain"> puppeteer</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><ol start="2"><li>Install dependencies</li></ol><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">install</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><ol start="3"><li>Run Puppeteer tests locally. For more information about tests, read <a href="#running--writing-tests">Running &amp; Writing Tests</a>.</li></ol><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> run test:unit</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="code-reviews">Code reviews<a class="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
<a href="https://help.github.com/articles/about-pull-requests/" target="_blank" rel="noopener noreferrer">GitHub Help</a> for more
information on using pull requests.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="code-style">Code Style<a class="hash-link" href="#code-style" title="Direct link to heading"></a></h2><ul><li>Coding style is fully defined in <a href="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 <a href="https://prettier.io" target="_blank" rel="noopener noreferrer">Prettier</a>.</li><li>It&#x27;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&#x27;re working in a JS file, code should be annotated with <a href="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&#x27;re working in a TS file, you should explicitly type all variables and return types. You&#x27;ll get ESLint warnings if you don&#x27;t so if you&#x27;re not sure use them as guidelines, and feel free to ask us for help!</li></ul><p>To run ESLint, use:</p><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> run lint:eslint</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="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><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> run build</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="typescript-guidelines">TypeScript guidelines<a class="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><h2 class="anchor anchorWithStickyNavbar_LWe7" id="project-structure-and-typescript-compilation">Project structure and TypeScript compilation<a class="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&#x27;ve vendored into the codebase. See the <a href="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><p>We structure these using TypeScript&#x27;s project references, which lets us treat each folder like a standalone TypeScript project.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="shipping-cjs-and-esm-bundles">Shipping CJS and ESM bundles<a class="hash-link" href="#shipping-cjs-and-esm-bundles" title="Direct link to heading"></a></h3><p>Currently Puppeteer ships both CommonJS and ESM, 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 outputting to CJS and another time to output to ESM.</p><p>We compile into the <code>lib</code> directory which is what we publish on the npm repository and it&#x27;s structured like so:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">lib</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">- cjs</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> - puppeteer &lt;== the output of compiling `src/tsconfig.cjs.json`</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> - vendor &lt;== the output of compiling `vendor/tsconfig.cjs.json`</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">- esm</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> - puppeteer &lt;== the output of compiling `src/tsconfig.esm.json`</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> - vendor &lt;== the output of compiling `vendor/tsconfig.esm.json`</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="tsconfig-for-the-tests">tsconfig for the tests<a class="hash-link" href="#tsconfig-for-the-tests" title="Direct link to heading"></a></h3><p>We also maintain <code>test/tsconfig.test.json</code>. This is <strong>only used to compile the unit test <code>*.spec.ts</code> files</strong>. When the tests are run, we first compile Puppeteer as normal before running the unit tests <strong>against the compiled output</strong>. Doing this lets the test run against the compiled code we ship to users so it gives us more confidence in our compiled output being correct.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="root-tsconfigjson">Root <code>tsconfig.json</code><a class="hash-link" href="#root-tsconfigjson" title="Direct link to heading"></a></h3><p>The root <code>tsconfig.json</code> exists for the API Extractor; it has to find a <code>tsconfig.json</code> in the project&#x27;s root directory. It is <em>not</em> used for anything else.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="api-guidelines">API guidelines<a class="hash-link" href="#api-guidelines" title="Direct link to heading"></a></h2><p>When authoring new API methods, consider the following:</p><ul><li>Expose as little information as needed. When in doubt, dont expose new information.</li><li>Methods are used in favor of getters/setters.<ul><li>The only exception is namespaces, e.g. <code>page.keyboard</code> and <code>page.coverage</code></li></ul></li><li>All string literals must be small case. This includes event names and option values.</li><li>Avoid adding &quot;sugar&quot; API (API that is trivially implementable in user-space) unless they&#x27;re <strong>very</strong> demanded.</li></ul><h2 class="anchor anchorWithStickyNavbar_LWe7" id="commit-messages">Commit Messages<a class="hash-link" href="#commit-messages" title="Direct link to heading"></a></h2><p>Commit messages should follow <a href="https://www.conventionalcommits.org/en/v1.0.0/#summary" target="_blank" rel="noopener noreferrer">the Conventional Commits format</a>. This is enforced via <code>npm run lint</code>.</p><p>In particular, breaking changes should clearly be noted as “BREAKING CHANGE:” in the commit message footer. Example:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">fix(page): fix page.pizza method</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">This patch fixes page.pizza so that it works with iframes.</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">Issues: #123, #234</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">BREAKING CHANGE: page.pizza now delivers pizza at home by default.</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">To deliver to a different location, use the &quot;deliver&quot; option:</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> `page.pizza({deliver: &#x27;work&#x27;})`.</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="writing-documentation">Writing Documentation<a class="hash-link" href="#writing-documentation" title="Direct link to heading"></a></h2><p>Documentation are generated via <code>npm run docs</code>. They are automatically published to our documentation site on merge and get versioned on release.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="writing-tsdoc-comments">Writing TSDoc Comments<a class="hash-link" href="#writing-tsdoc-comments" title="Direct link to heading"></a></h2><p>Each change to Puppeteer should be thoroughly documented using TSDoc comments. Refer to the <a href="https://api-extractor.com/pages/tsdoc/doc_comment_syntax/" target="_blank" rel="noopener noreferrer">API Extractor documentation</a> for information on the exact syntax.</p><ul><li>Every new method needs to have either <code>@public</code> or <code>@internal</code> added as a tag depending on if it is part of the public API.</li><li>Keep each line in a comment to no more than 90 characters (ESLint will warn you if you go over this). If you&#x27;re a VSCode user the <a href="https://marketplace.visualstudio.com/items?itemName=stkb.rewrap" target="_blank" rel="noopener noreferrer">Rewrap plugin</a> is highly recommended!</li></ul><h2 class="anchor anchorWithStickyNavbar_LWe7" id="running-new-documentation-website-locally">Running New Documentation website locally<a class="hash-link" href="#running-new-documentation-website-locally" title="Direct link to heading"></a></h2><ul><li>In the Puppeteer&#x27;s folder, install all dependencies with <code>npm i</code>.</li><li>run <code>npm run generate:docs</code> which will generate all the <code>.md</code> files on <code>puppeteer/website/docs</code>.</li><li>run <code>npm i</code> on <code>puppeteer/website</code>.</li><li>run <code>npm start</code> on <code>puppeteer/website</code>.</li></ul><h2 class="anchor anchorWithStickyNavbar_LWe7" id="adding-new-dependencies">Adding New Dependencies<a class="hash-link" href="#adding-new-dependencies" title="Direct link to heading"></a></h2><p>For all dependencies (both installation and development):</p><ul><li><strong>Do not add</strong> a dependency if the desired functionality is easily implementable.</li><li>If adding a dependency, it should be well-maintained and trustworthy.</li></ul><p>A barrier for introducing new installation dependencies is especially high:</p><ul><li><strong>Do not add</strong> installation dependency unless it&#x27;s critical to project success.</li></ul><p>There are additional considerations for dependencies that are environment agonistic. See the <a href="https://github.com/puppeteer/puppeteer/blob/main/vendor/README.md" target="_blank" rel="noopener noreferrer"><code>vendor/README.md</code></a> for details.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="running--writing-tests">Running &amp; Writing Tests<a class="hash-link" href="#running--writing-tests" title="Direct link to heading"></a></h2><ul><li>Every feature should be accompanied by a test.</li><li>Every public api event/method should be accompanied by a test.</li><li>Tests should not depend on external services.</li><li>Tests should work on all three platforms: Mac, Linux and Win. This is especially important for screenshot tests.</li></ul><p>Puppeteer tests are located in <a href="https://github.com/puppeteer/puppeteer/blob/main/test/" target="_blank" rel="noopener noreferrer">the <code>test</code> directory</a> and are written using Mocha. See <a href="https://github.com/puppeteer/puppeteer/blob/main/test/README.md" target="_blank" rel="noopener noreferrer"><code>test/README.md</code></a> for more details.</p><p>Despite being named &#x27;unit&#x27;, these are integration tests, making sure public API methods and events work as expected.</p><ul><li>To run all tests:</li></ul><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> run test:unit</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><ul><li>To run a specific test, substitute the <code>it</code> with <code>it.only</code>:</li></ul><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-js codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token spread operator" style="color:#393A34">...</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> it</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">only</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">&#x27;should work&#x27;</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">function</span><span class="token punctuation" style="color:#393A34">(</span><span class="token parameter punctuation" style="color:#393A34">{</span><span class="token parameter">server</span><span class="token parameter punctuation" style="color:#393A34">,</span><span class="token parameter"> page</span><span class="token parameter punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> response </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword control-flow" style="color:#00009f">await</span><span class="token plain"> page</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">goto</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">server</span><span class="token punctuation" style="color:#393A34">.</span><span class="token constant" style="color:#36acaa">EMPTY_PAGE</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token function" style="color:#d73a49">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">response</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">ok</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">toBe</span><span class="token punctuation" style="color:#393A34">(</span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><ul><li>To disable a specific test, substitute the <code>it</code> with <code>xit</code> (mnemonic rule: &#x27;<em>cross it</em>&#x27;):</li></ul><div class="language-js codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-js codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token spread operator" style="color:#393A34">...</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic">// Using &quot;xit&quot; to skip specific test</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token function" style="color:#d73a49">xit</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string" style="color:#e3116c">&#x27;should work&#x27;</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">async</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">function</span><span class="token punctuation" style="color:#393A34">(</span><span class="token parameter punctuation" style="color:#393A34">{</span><span class="token parameter">server</span><span class="token parameter punctuation" style="color:#393A34">,</span><span class="token parameter"> page</span><span class="token parameter punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token keyword" style="color:#00009f">const</span><span class="token plain"> response </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token keyword control-flow" style="color:#00009f">await</span><span class="token plain"> page</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">goto</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">server</span><span class="token punctuation" style="color:#393A34">.</span><span class="token constant" style="color:#36acaa">EMPTY_PAGE</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token function" style="color:#d73a49">expect</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">response</span><span class="token punctuation" style="color:#393A34">.</span><span class="token property-access">ok</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">.</span><span class="token method function property-access" style="color:#d73a49">toBe</span><span class="token punctuation" style="color:#393A34">(</span><span class="token boolean" style="color:#36acaa">true</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><ul><li>To run tests in non-headless mode:</li></ul><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token assign-left variable" style="color:#36acaa">HEADLESS</span><span class="token operator" style="color:#393A34">=</span><span class="token plain">false </span><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> run test:unit</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><ul><li>To run Firefox tests, firstly ensure you have Firefox installed locally (you only need to do this once, not on every test run) and then you can run the tests:</li></ul><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token assign-left variable" style="color:#36acaa">PUPPETEER_PRODUCT</span><span class="token operator" style="color:#393A34">=</span><span class="token plain">firefox </span><span class="token function" style="color:#d73a49">node</span><span class="token plain"> install.js</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token assign-left variable" style="color:#36acaa">PUPPETEER_PRODUCT</span><span class="token operator" style="color:#393A34">=</span><span class="token plain">firefox </span><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> run test:unit</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><ul><li>To run experimental Chromium MacOS ARM tests, firstly ensure you have correct Chromium version installed locally (you only need to do this once, not on every test run) and then you can run the tests:</li></ul><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token assign-left variable" style="color:#36acaa">PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM</span><span class="token operator" style="color:#393A34">=</span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">node</span><span class="token plain"> install.js</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token assign-left variable" style="color:#36acaa">PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM</span><span class="token operator" style="color:#393A34">=</span><span class="token number" style="color:#36acaa">1</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> run test:unit</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><ul><li>To run tests with custom browser executable:</li></ul><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token assign-left variable" style="color:#36acaa">BINARY</span><span class="token operator" style="color:#393A34">=</span><span class="token operator" style="color:#393A34">&lt;</span><span class="token plain">path-to-executable</span><span class="token operator" style="color:#393A34">&gt;</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> run test:unit</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="public-api-coverage">Public API Coverage<a class="hash-link" href="#public-api-coverage" title="Direct link to heading"></a></h2><p>Every public API method or event should be called at least once in tests. To ensure this, there&#x27;s a <code>coverage</code> command which tracks calls to public API and reports back if some methods/events were not called.</p><p>Run coverage:</p><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">npm</span><span class="token plain"> run coverage</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="debugging-puppeteer">Debugging Puppeteer<a class="hash-link" href="#debugging-puppeteer" title="Direct link to heading"></a></h2><p>See <a href="https://github.com/puppeteer/puppeteer/blob/main/README.md#debugging-tips" target="_blank" rel="noopener noreferrer">Debugging Tips</a> in the readme.</p><h1>For Project Maintainers</h1><h2 class="anchor anchorWithStickyNavbar_LWe7" id="rolling-new-chromium-version">Rolling new Chromium version<a class="hash-link" href="#rolling-new-chromium-version" title="Direct link to heading"></a></h2><p>The following steps are needed to update the Chromium version.</p><ol><li>Find a suitable Chromium revision
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, <a href="#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 its not desirable to change Puppeteers observable behavior).</li><li>Commit and push your changes and open a pull request.
The commit message must contain the version in <code>Chromium &lt;version&gt; (&lt;revision&gt;)</code> format to ensure that <a href="https://pptr.dev/" target="_blank" rel="noopener noreferrer">pptr.dev</a> can parse it correctly, e.g. <code>&#x27;feat(chromium): roll to Chromium 90.0.4427.0 (r856583)&#x27;</code>.</li></ol><h3 class="anchor anchorWithStickyNavbar_LWe7" id="bisecting-upstream-changes">Bisecting upstream changes<a class="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><div class="language-sh codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-sh codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">node utils/bisect.js --good 686378 --bad 706915 script.js</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">node utils/bisect.js --unit-test Response.fromCache</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="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><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="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><h2 class="anchor anchorWithStickyNavbar_LWe7" id="releasing-to-npm">Releasing to npm<a class="hash-link" href="#releasing-to-npm" title="Direct link to heading"></a></h2><p>We use <a href="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 <a href="https://github.com/puppeteer/puppeteer/pulls" target="_blank" rel="noopener noreferrer">pull requests</a> and merge it.</p></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><a class="pagination-nav__link pagination-nav__link--prev" href="/puppeteer/troubleshooting"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Troubleshooting</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/puppeteer/chromium-support"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Chromium Support</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#contributor-license-agreement" class="table-of-contents__link toc-highlight">Contributor License Agreement</a></li><li><a href="#getting-code" class="table-of-contents__link toc-highlight">Getting Code</a></li><li><a href="#code-reviews" class="table-of-contents__link toc-highlight">Code reviews</a></li><li><a href="#code-style" class="table-of-contents__link toc-highlight">Code Style</a></li><li><a href="#typescript-guidelines" class="table-of-contents__link toc-highlight">TypeScript guidelines</a></li><li><a href="#project-structure-and-typescript-compilation" class="table-of-contents__link toc-highlight">Project structure and TypeScript compilation</a><ul><li><a href="#shipping-cjs-and-esm-bundles" class="table-of-contents__link toc-highlight">Shipping CJS and ESM bundles</a></li><li><a href="#tsconfig-for-the-tests" class="table-of-contents__link toc-highlight">tsconfig for the tests</a></li><li><a href="#root-tsconfigjson" class="table-of-contents__link toc-highlight">Root <code>tsconfig.json</code></a></li></ul></li><li><a href="#api-guidelines" class="table-of-contents__link toc-highlight">API guidelines</a></li><li><a href="#commit-messages" class="table-of-contents__link toc-highlight">Commit Messages</a></li><li><a href="#writing-documentation" class="table-of-contents__link toc-highlight">Writing Documentation</a></li><li><a href="#writing-tsdoc-comments" class="table-of-contents__link toc-highlight">Writing TSDoc Comments</a></li><li><a href="#running-new-documentation-website-locally" class="table-of-contents__link toc-highlight">Running New Documentation website locally</a></li><li><a href="#adding-new-dependencies" class="table-of-contents__link toc-highlight">Adding New Dependencies</a></li><li><a href="#running--writing-tests" class="table-of-contents__link toc-highlight">Running &amp; Writing Tests</a></li><li><a href="#public-api-coverage" class="table-of-contents__link toc-highlight">Public API Coverage</a></li><li><a href="#debugging-puppeteer" class="table-of-contents__link toc-highlight">Debugging Puppeteer</a></li><li><a href="#rolling-new-chromium-version" class="table-of-contents__link toc-highlight">Rolling new Chromium version</a><ul><li><a href="#bisecting-upstream-changes" class="table-of-contents__link toc-highlight">Bisecting upstream changes</a></li></ul></li><li><a href="#releasing-to-npm" class="table-of-contents__link toc-highlight">Releasing to npm</a></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/puppeteer" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_lCJq"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://twitter.com/chromedevtools" target="_blank" rel="noopener noreferrer" class="footer__link-item">Twitter<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_lCJq"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://goo.gle/devtools-youtube" target="_blank" rel="noopener noreferrer" class="footer__link-item">YouTube<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_lCJq"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2022 Google, Inc.</div></div></div></footer></div>
<script src="/puppeteer/assets/js/runtime~main.e41f0c35.js"></script>
<script src="/puppeteer/assets/js/main.8e9e8b27.js"></script>
</body>
</html>