Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion packages/vue/test/integration/vue-pages-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@
await browser?.close();
});

async function prepareForViteHmr(page: Page) {
await page.addInitScript(() => {
const marker = "__void_vite_connected";
const patched = "__void_vite_console_patched";
if ((window as any)[patched]) return;

const originalDebug = console.debug.bind(console);
console.debug = (...args: unknown[]) => {
if (args.some((arg) => typeof arg === "string" && arg.includes("[vite] connected."))) {
(window as any)[marker] = true;
}
originalDebug(...args);
};

(window as any)[patched] = true;
});
}

async function waitForViteHmr(page: Page) {
await page.waitForFunction(() => (window as any).__void_vite_connected === true, {
timeout: 15_000,
});
}

function defineClientTests(getBase: () => string) {
let BASE: string;
beforeAll(() => {
Expand Down Expand Up @@ -657,8 +681,10 @@
page.setDefaultTimeout(10_000);

try {
await prepareForViteHmr(page);
await page.goto(`${DEV_BASE}/deferred`);
await page.waitForSelector('#app[data-hydrated="true"]');
await waitForViteHmr(page);
await page.waitForFunction(
() => document.querySelector("h1")?.textContent === "Deferred Page",
);
Expand Down Expand Up @@ -708,7 +734,7 @@
if (hmrDelivered) {
// Verify it was a hot update, not a full page reload
const markerSurvived = await page.evaluate(() => (window as any).__hmr_marker === true);
expect(markerSurvived).toBe(true);

Check warning on line 737 in packages/vue/test/integration/vue-pages-client.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check

eslint-plugin-jest(no-conditional-expect)

Unexpected conditional expect
}
} finally {
await page.context().close();
Expand All @@ -727,8 +753,10 @@
page.setDefaultTimeout(10_000);

try {
await prepareForViteHmr(page);
await page.goto(`${DEV_BASE}/blog`);
await page.waitForSelector('[data-island][data-hydrated="true"]');
await waitForViteHmr(page);

// Interact to establish client state — count becomes 1
await page.click("button:has-text('Increment')");
Expand All @@ -748,7 +776,7 @@
// Wait for HMR to update the component text
await page.waitForFunction(
() => document.querySelector('[data-testid="count"]')?.textContent?.startsWith("Total:"),
{ timeout: 10_000 },
{ timeout: 15_000 },
);

// No full page reload — window marker should still be set
Expand Down Expand Up @@ -803,7 +831,7 @@
});
}, 60_000);

describe("vue-pages client (preview)", { retry: 2, timeout: 60_000 }, () => {

Check warning on line 834 in packages/vue/test/integration/vue-pages-client.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check

eslint-plugin-jest(valid-describe-callback)

Second argument must be a function
let child: ReturnType<typeof spawn>;
let stderr = "";

Expand Down
Loading