Skip to content

Commit

Permalink
test: no partytown script
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Mar 7, 2022
1 parent a7693e6 commit 53502c9
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ <h2>Platform Tests</h2>
<li><a href="/tests/platform/mutation-observer/">MutationObserver</a></li>
<li><a href="/tests/platform/navigator/">Navigator</a></li>
<li><a href="/tests/platform/node/">Node</a></li>
<li><a href="/tests/platform/no-partytown-script/">No Partytown</a></li>
<li><a href="/tests/platform/resize-observer/">ResizeObserver</a></li>
<li><a href="/tests/platform/screen/">Screen</a></li>
<li><a href="/tests/platform/script/">Script</a></li>
Expand Down
92 changes: 92 additions & 0 deletions tests/platform/no-partytown-script/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Partytown Test Page" />
<title>No Partytown Script</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif,
Apple Color Emoji, Segoe UI Emoji;
font-size: 12px;
}
h1 {
margin: 0 0 15px 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
a {
display: block;
padding: 16px 8px;
}
a:link,
a:visited {
text-decoration: none;
color: blue;
}
a:hover {
background-color: #eee;
}
strong a {
display: inline-block;
}
li {
display: flex;
margin: 15px 0;
}
li strong,
li code,
li button,
li a {
white-space: nowrap;
flex: 1;
margin: 0 5px;
padding: 0;
}
</style>
<script>
window.pageErrors = [];
window.addEventListener('error', (ev) => {
window.pageErrors.push(ev.message);
});
</script>
<script>
partytown = {
logCalls: true,
logGetters: true,
logSetters: true,
logStackTraces: false,
logScriptExecution: true,
};
</script>
<script src="/~partytown/debug/partytown.js"></script>
</head>
<body>
<h1>No Partytown Script</h1>

<p>
Tests initializing Partytown, however, the page has no text/partytown scripts. Ensure there's
no runtime errors.
</p>

<ul>
<li>
<strong>Page Errors</strong>
<code id="testPageErrors">--</code>
<script>
// used for e2e testing a page w/out Partytown
if (window.pageErrors.length > 0) {
document.getElementById('testPageErrors').textContent = window.pageErrors.join('<br>');
}
</script>
</li>
</ul>

<hr />
<p><a href="/tests/">All Tests</a></p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from '@playwright/test';

test('no-partytown-script', async ({ page }) => {
await page.goto('/tests/platform/no-partytown-script/');

const testPageErrors = page.locator('#testPageErrors');
await expect(testPageErrors).toHaveText('--');
});

0 comments on commit 53502c9

Please sign in to comment.