Skip to content

Commit

Permalink
test: write the test some other way to try to convince playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Jan 3, 2024
1 parent 7723c01 commit 8cbb65d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/astro/e2e/custom-client-directives.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ function testClientDirectivesShared() {
test('Client directives should be passed options correctly', async ({ astro, page }) => {
await page.goto(astro.resolveUrl('/'));

const optionsContent = page.locator('#client-has-options pre');
await waitForHydrate(page, optionsContent);

const clientOptions = page.locator('#options');
await expect(clientOptions).toHaveText(
'Passed options are: {"message":"Hello! I was passed as an option"}'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Hydrate directly and write the passed options to the DOM
export default async (load, options) => {
const hydrate = await load()
document.write(`<div id="options">Passed options are: ${JSON.stringify(options.value)}</div>`)
await hydrate()
const hydrate = await load();

const div = document.createElement('div');
div.id = 'options';
div.textContent = `Passed options are: ${JSON.stringify(options.value)}`;
document.body.appendChild(div);
await hydrate();
}

0 comments on commit 8cbb65d

Please sign in to comment.