<!DOCTYPE html><htmlclass="default"lang="en"><head><metacharSet="utf-8"/><metahttp-equiv="x-ua-compatible"content="IE=edge"/><title>@waku/browser-tests | Documentation</title><metaname="description"content="Documentation for Documentation"/><metaname="viewport"content="width=device-width, initial-scale=1"/><linkrel="stylesheet"href="../assets/style.css"/><linkrel="stylesheet"href="../assets/highlight.css"/><scriptdefersrc="../assets/main.js"></script><scriptasyncsrc="../assets/icons.js"id="tsd-icons-script"></script><scriptasyncsrc="../assets/search.js"id="tsd-search-script"></script><scriptasyncsrc="../assets/navigation.js"id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme=localStorage.getItem("tsd-theme")||"os";document.body.style.display="none";setTimeout(()=>app?app.showPage():document.body.style.removeProperty("display"),500)</script><headerclass="tsd-page-toolbar"><divclass="tsd-toolbar-contents container"><divclass="table-cell"id="tsd-search"data-base=".."><divclass="field"><labelfor="tsd-search-field"class="tsd-widget tsd-toolbar-icon search no-caption"><svgwidth="16"height="16"viewBox="0 0 16 16"fill="none"><usehref="../assets/icons.svg#icon-search"></use></svg></label><inputtype="text"id="tsd-search-field"aria-label="Search"/></div><divclass="field"><divid="tsd-toolbar-links"></div></div><ulclass="results"><liclass="state loading">Preparing search index...</li><liclass="state failure">The search index is not available</li></ul><ahref="../index.html"class="title">Documentation</a></div><divclass="table-cell"id="tsd-widgets"><ahref="#"class="tsd-widget tsd-toolbar-icon menu no-caption"data-toggle="menu"aria-label="Menu"><svgwidth="16"height="16"viewBox="0 0 16 16"fill="none"><usehref="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><divclass="container container-main"><divclass="col-content"><divclass="tsd-page-title"><ulclass="tsd-breadcrumb"><li><ahref="../index.html">Documentation</a></li><li><ahref="_waku_browser_tests.html">@waku/browser-tests</a></li></ul><h1>Module @waku/browser-tests</h1></div><sectionclass="tsd-panel tsd-typography"><aid="md:waku-browser-tests"class="tsd-anchor"></a><h1><ahref="#md:waku-browser-tests">Waku Browser Tests</a></h1><p>This project provides a system for testing the Waku SDK in a browser environment.</p>
<aid="md:architecture"class="tsd-anchor"></a><h2><ahref="#md:architecture">Architecture</a></h2><p>The system consists of:</p>
<ol>
<li><strong>Headless Web App</strong>: A simple web application (in the <code>@waku/headless-tests</code> package) that loads the Waku SDK and exposes shared API functions.</li>
<li><strong>Express Server</strong>: A server that communicates with the headless app using Playwright.</li>
<li><strong>Shared API</strong>: TypeScript functions shared between the server and web app.</li>
<li><code>GET /info</code>: Get information about the Waku node</li>
<li><code>GET /debug/v1/info</code>: Get debug information from the Waku node</li>
<li><code>POST /push</code>: Push a message to the Waku network (legacy)</li>
<li><code>POST /lightpush/v1/message</code>: Push a message to the Waku network (Waku REST API compatible)</li>
<li><code>POST /admin/v1/create-node</code>: Create a new Waku node (requires networkConfig)</li>
<li><code>POST /admin/v1/start-node</code>: Start the Waku node</li>
<li><code>POST /admin/v1/stop-node</code>: Stop the Waku node</li>
<li><code>POST /admin/v1/peers</code>: Dial to specified peers (Waku REST API compatible)</li>
<li><code>GET /filter/v2/messages/:contentTopic</code>: Subscribe to messages on a specific content topic using Server-Sent Events (Waku REST API compatible)</li>
<li><code>GET /filter/v1/messages/:contentTopic</code>: Retrieve stored messages from a content topic (Waku REST API compatible)</li>
<aid="md:example-pushing-a-message-with-the-legacy-endpoint"class="tsd-anchor"></a><h3><ahref="#md:example-pushing-a-message-with-the-legacy-endpoint">Example: Pushing a message with the legacy endpoint</a></h3><pre><codeclass="language-bash"><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-X</span><spanclass="hl-1"></span><spanclass="hl-2">POST</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/push</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-H</span><spanclass="hl-1"></span><spanclass="hl-2">"Content-Type: application/json"</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-d</span><spanclass="hl-1"></span><spanclass="hl-2">'{"contentTopic": "/toy-chat/2/huilong/proto", "payload": [1, 2, 3]}'</span>
</code><button>Copy</button></pre>
<aid="md:example-pushing-a-message-with-the-waku-rest-api-compatible-endpoint"class="tsd-anchor"></a><h3><ahref="#md:example-pushing-a-message-with-the-waku-rest-api-compatible-endpoint">Example: Pushing a message with the Waku REST API compatible endpoint</a></h3><pre><codeclass="language-bash"><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-X</span><spanclass="hl-1"></span><spanclass="hl-2">POST</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/lightpush/v1/message</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-H</span><spanclass="hl-1"></span><spanclass="hl-2">"Content-Type: application/json"</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-d</span><spanclass="hl-1"></span><spanclass="hl-2">'{</span><br/><spanclass="hl-2">"pubsubTopic": "/waku/2/rs/0/0",</span><br/><spanclass="hl-2">"message": {</span><br/><spanclass="hl-2">"payload": "SGVsbG8sIFdha3Uh",</span><br/><spanclass="hl-2">"contentTopic": "/toy-chat/2/huilong/proto",</span><br/><spanclass="hl-2">"timestamp": 1712135330213797632</span><br/><spanclass="hl-2"> }</span><br/><spanclass="hl-2"> }'</span>
</code><button>Copy</button></pre>
<aid="md:example-executing-a-function"class="tsd-anchor"></a><h3><ahref="#md:example-executing-a-function">Example: Executing a function</a></h3><pre><codeclass="language-bash"><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-X</span><spanclass="hl-1"></span><spanclass="hl-2">POST</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/execute</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-H</span><spanclass="hl-1"></span><spanclass="hl-2">"Content-Type: application/json"</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-d</span><spanclass="hl-1"></span><spanclass="hl-2">'{"functionName": "getPeerInfo", "params": []}'</span>
<aid="md:example-starting-and-stopping-a-waku-node"class="tsd-anchor"></a><h3><ahref="#md:example-starting-and-stopping-a-waku-node">Example: Starting and stopping a Waku node</a></h3><pre><codeclass="language-bash"><spanclass="hl-4"># Start the node</span><br/><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-X</span><spanclass="hl-1"></span><spanclass="hl-2">POST</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/admin/v1/start-node</span><br/><br/><spanclass="hl-4"># Stop the node</span><br/><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-X</span><spanclass="hl-1"></span><spanclass="hl-2">POST</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/admin/v1/stop-node</span>
</code><button>Copy</button></pre>
<aid="md:example-dialing-to-specific-peers-with-the-waku-rest-api-compatible-endpoint"class="tsd-anchor"></a><h3><ahref="#md:example-dialing-to-specific-peers-with-the-waku-rest-api-compatible-endpoint">Example: Dialing to specific peers with the Waku REST API compatible endpoint</a></h3><pre><codeclass="language-bash"><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-X</span><spanclass="hl-1"></span><spanclass="hl-2">POST</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/admin/v1/peers</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-H</span><spanclass="hl-1"></span><spanclass="hl-2">"Content-Type: application/json"</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-d</span><spanclass="hl-1"></span><spanclass="hl-2">'{</span><br/><spanclass="hl-2">"peerMultiaddrs": [</span><br/><spanclass="hl-2">"/ip4/127.0.0.1/tcp/8000/p2p/16Uiu2HAm4v8KuHUH6Cwz3upPeQbkyxQJsFGPdt7kHtkN8F79QiE6"]</span><br/><spanclass="hl-2"> ]</span><br/><spanclass="hl-2"> }'</span>
</code><button>Copy</button></pre>
<aid="md:example-dialing-to-specific-peers-with-the-execute-endpoint"class="tsd-anchor"></a><h3><ahref="#md:example-dialing-to-specific-peers-with-the-execute-endpoint">Example: Dialing to specific peers with the execute endpoint</a></h3><pre><codeclass="language-bash"><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-X</span><spanclass="hl-1"></span><spanclass="hl-2">POST</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/execute</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-H</span><spanclass="hl-1"></span><spanclass="hl-2">"Content-Type: application/json"</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-d</span><spanclass="hl-1"></span><spanclass="hl-2">'{</span><br/><spanclass="hl-2">"functionName": "dialPeers", </span><br/><spanclass="hl-2">"params": [</span><br/><spanclass="hl-2"> ["/ip4/127.0.0.1/tcp/8000/p2p/16Uiu2HAm4v8KuHUH6Cwz3upPeQbkyxQJsFGPdt7kHtkN8F79QiE6"]</span><br/><spanclass="hl-2"> ]</span><br/><spanclass="hl-2"> }'</span>
</code><button>Copy</button></pre>
<aid="md:example-subscribing-to-a-content-topic-with-the-filter-endpoint"class="tsd-anchor"></a><h3><ahref="#md:example-subscribing-to-a-content-topic-with-the-filter-endpoint">Example: Subscribing to a content topic with the filter endpoint</a></h3><pre><codeclass="language-bash"><spanclass="hl-4"># Open a persistent connection to receive messages as Server-Sent Events</span><br/><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-N</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/filter/v2/messages/%2Ftoy-chat%2F2%2Fhuilong%2Fproto</span><br/><br/><spanclass="hl-4"># You can also specify clustering options</span><br/><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-N</span><spanclass="hl-1"></span><spanclass="hl-2">"http://localhost:3000/filter/v2/messages/%2Ftoy-chat%2F2%2Fhuilong%2Fproto?clusterId=0&shard=0"</span>
</code><button>Copy</button></pre>
<aid="md:example-retrieving-stored-messages-from-a-content-topic"class="tsd-anchor"></a><h3><ahref="#md:example-retrieving-stored-messages-from-a-content-topic">Example: Retrieving stored messages from a content topic</a></h3><pre><codeclass="language-bash"><spanclass="hl-4"># Get the most recent 20 messages</span><br/><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/filter/v1/messages/%2Ftoy-chat%2F2%2Fhuilong%2Fproto</span><br/><br/><spanclass="hl-4"># Get messages with pagination and time filtering</span><br/><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-2">"http://localhost:3000/filter/v1/messages/%2Ftoy-chat%2F2%2Fhuilong%2Fproto?pageSize=10&startTime=1712000000000&endTime=1713000000000&ascending=true"</span>
</code><button>Copy</button></pre>
<aid="md:extending"class="tsd-anchor"></a><h2><ahref="#md:extending">Extending</a></h2><p>To add new functionality:</p>
<ol>
<li>Add your function to <code>src/api/shared.ts</code></li>
<li>Add your function to the <code>API</code> object in <code>src/api/shared.ts</code></li>
<li>Use it via the server endpoints</li>
</ol>
<aid="md:example-dialing-to-specific-peers"class="tsd-anchor"></a><h3><ahref="#md:example-dialing-to-specific-peers">Example: Dialing to specific peers</a></h3><pre><codeclass="language-bash"><spanclass="hl-0">curl</span><spanclass="hl-1"></span><spanclass="hl-5">-X</span><spanclass="hl-1"></span><spanclass="hl-2">POST</span><spanclass="hl-1"></span><spanclass="hl-2">http://localhost:3000/execute</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-H</span><spanclass="hl-1"></span><spanclass="hl-2">"Content-Type: application/json"</span><spanclass="hl-1"></span><spanclass="hl-10">\</span><br/><spanclass="hl-1"></span><spanclass="hl-5">-d</span><spanclass="hl-1"></span><spanclass="hl-2">'{</span><br/><spanclass="hl-2">"functionName": "dialPeers", </span><br/><spanclass="hl-2">"params": [</span><br/><spanclass="hl-2"> ["/ip4/127.0.0.1/tcp/8000/p2p/16Uiu2HAm4v8KuHUH6Cwz3upPeQbkyxQJsFGPdt7kHtkN8F79QiE6"]</span><br/><spanclass="hl-2"> ]</span><br/><spanclass="hl-2"> }'</span>
</code><button>Copy</button></pre>
</section></div><divclass="col-sidebar"><divclass="page-menu"><divclass="tsd-navigation settings"><detailsclass="tsd-index-accordion"><summaryclass="tsd-accordion-summary"><h3><svgwidth="20"height="20"viewBox="0 0 24 24"fill="none"><usehref="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><divclass="tsd-accordion-details"><divclass="tsd-filter-visibility"><h4class="uppercase">Member Visibility</h4><form><ulid="tsd-filter-options"><liclass="tsd-filter-item"><labelclass="tsd-filter-input"><inputtype="checkbox"id="tsd-filter-protected"name="protected"/><svgwidth="32"height="32"viewBox="0 0 32 32"aria-hidden="true"><rectclass="tsd-checkbox-background"width="30"height="30"x="1"y="1"rx="6"fill="none"></rect><pathclass="tsd-checkbox-checkmark"d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25"stroke="none"stroke-width="3.5"stroke-linejoin="round"fill="none"></path></svg><span>Protected</span></label></li><liclass="tsd-filter-item"><labelclass="tsd-filter-input"><inputtype="checkbox"id="tsd-filter-private"name="private"/><svgwidth="32"height="32"viewBox="0 0 32 32"aria-hidden="true"><rectclass="tsd-checkbox-background"width="30"height="30"x="1"y="1"rx="6"fill="none"></rect><pathclass="tsd-checkbox-checkmark"d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25"stroke="none"stroke-width="3.5"stroke-linejoin="round"fill="none"></path></svg><span>Private</span></label></li><liclass="tsd-filter-item"><labelclass="tsd-filter-input"><inputtype="checkbox"id="tsd-filter-inherited"name="inherited"checked/><svgwidth="32"height="32"viewBox="0 0 32 32"aria-hidden="true"><rectclass="tsd-checkbox-background"width="30"height="30"x="1"y="1"rx="6"fill="none"></rect><pathclass="tsd-checkbox-checkmark"d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25"stroke="none"stroke-width="3.5"stroke-linejoin="round"fill="none"></path></svg><span>Inherited</span></label></li></ul></form></div><divclass="tsd-theme-toggle"><h4class="uppercase">Theme</h4><selectid="tsd-theme"><optionvalue="os">OS</option><optionvalue="light">Light</option><optionvalue="dark">Dark</option></select></div></div></details></div><detailsopenclass="tsd-index-accordion tsd-page-navigation"><summaryclass="tsd-accordion-summary"><h3><svgwidth="20"height="20"viewBox="0 0 24 24"fill="none"><usehref="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><divclass="tsd-accordion-details"><ahref="#md:waku-browser-tests"><span>Waku <wbr/>Browser <wbr/>Tests</span></a><ul><li><ahref="#md:architecture"><span>Architecture</span></a></li><li><ahref="#md:setup"><span>Setup</span></a></li><li><ahref="#md:running"><span>Running</span></a></li><li><ahref="#md:api-endpoints"><span>API <wbr/>Endpoints</span></a></li><li><ul><li><ahref="#md:example-pushing-a-message-with-the-legacy-endpoint"><span>Example: <wbr/>Pushing a message with the legacy endpoint</span></a></li><li><ahref="#md:example-pushing-a-message-with-the-waku-rest-api-compatible-endpoint"><span>Example: <wbr/>Pushing a message with the <wbr/>Waku REST API compatible endpoint</span></a></li><li><ahref="#md:example-executing-a-function"><span>Example: <wbr/>Executing a function</span></a></li><li><ahref="#md:example-creating-a-waku-node"><span>Example: <wbr/>Creating a <wbr/>Waku node</span></a></li><li><ahref="#md:example-starting-and-stopping-a-waku-node"><span>Example: <wbr/>Starting and stopping a <wbr/>Waku node</span></a></li><li><ahref="#md:example-dialing-to-specific-peers-with-the-waku-rest-api-compatible-endpoint"><span>Example: <wbr/>Dialing to specific peers with the <wbr/>Waku REST API compatible endpoint</span></a></li><li><ahref="#md:example-dialing-to-specific-peers-with-the-execute-endpoint"><span>Example: <wbr/>Dialing to specific peers with the execute endpoint</span></a></li><li><ahref="#md:example-subscribing-to-a-content-topic-with-the-filter-endpoint"><span>Example: <wbr/>Subscribing to a content topic with the filter endpoint</span></a></li><li><ahref="#md:example-retrievin