From 8f5d9a0823f9ec827692e4b9c3e7ebf0590b4e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Tue, 21 May 2024 00:07:38 +0200 Subject: [PATCH] chore: update tests for compatibility with Vite 6 (#208) --- playground/hmr/__tests__/hmr.spec.ts | 2 +- playground/utils.ts | 10 ++++++++-- scripts/bundle.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/playground/hmr/__tests__/hmr.spec.ts b/playground/hmr/__tests__/hmr.spec.ts index 2d62485..0ff64a3 100644 --- a/playground/hmr/__tests__/hmr.spec.ts +++ b/playground/hmr/__tests__/hmr.spec.ts @@ -74,7 +74,7 @@ test("HMR invalidate", async ({ page }) => { await waitForLogs( "[vite] invalidate /src/TitleWithExport.tsx: Could not Fast Refresh (export removed)", "[vite] hot updated: /src/App.tsx", - "[hmr] Failed to reload /src/App.tsx. This could be due to syntax errors or importing non-existent modules. (see errors above)", + /Failed to reload \/src\/App\.tsx. This could be due to syntax errors or importing non-existent modules\. \(see errors above\)$/, ); // Remove usage from App diff --git a/playground/utils.ts b/playground/utils.ts index 851a3a3..c6c3605 100644 --- a/playground/utils.ts +++ b/playground/utils.ts @@ -13,10 +13,16 @@ export const setupWaitForLogs = async (page: Page) => { page.on("console", (log) => { logs.push(log.text()); }); - return (...messages: string[]) => + return (...messages: (string | RegExp)[]) => expect .poll(() => { - if (messages.every((m) => logs.includes(m))) { + if ( + messages.every((m) => + typeof m === "string" + ? logs.includes(m) + : logs.some((l) => m.test(l)), + ) + ) { logs = []; return true; } diff --git a/scripts/bundle.ts b/scripts/bundle.ts index 4740bd0..d88c6d6 100644 --- a/scripts/bundle.ts +++ b/scripts/bundle.ts @@ -57,7 +57,7 @@ module.exports.default = react;`, copyFileSync("README.md", "dist/README.md"); execSync( - "tsc src/index.ts --declaration --emitDeclarationOnly --outDir dist --module es2020 --moduleResolution bundler", + "tsc src/index.ts --declaration --emitDeclarationOnly --outDir dist --target es2020 --module es2020 --moduleResolution bundler", { stdio: "inherit" }, );