Skip to content

Commit 8cbb65d

Browse files
committed
test: write the test some other way to try to convince playwright
1 parent 7723c01 commit 8cbb65d

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

packages/astro/e2e/custom-client-directives.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ function testClientDirectivesShared() {
9393
test('Client directives should be passed options correctly', async ({ astro, page }) => {
9494
await page.goto(astro.resolveUrl('/'));
9595

96+
const optionsContent = page.locator('#client-has-options pre');
97+
await waitForHydrate(page, optionsContent);
98+
9699
const clientOptions = page.locator('#options');
97100
await expect(clientOptions).toHaveText(
98101
'Passed options are: {"message":"Hello! I was passed as an option"}'
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Hydrate directly and write the passed options to the DOM
22
export default async (load, options) => {
3-
const hydrate = await load()
4-
document.write(`<div id="options">Passed options are: ${JSON.stringify(options.value)}</div>`)
5-
await hydrate()
3+
const hydrate = await load();
4+
5+
const div = document.createElement('div');
6+
div.id = 'options';
7+
div.textContent = `Passed options are: ${JSON.stringify(options.value)}`;
8+
document.body.appendChild(div);
9+
await hydrate();
610
}

0 commit comments

Comments
 (0)