Migrate Cypress E2E from cy.intercept to MSW service worker

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 09:30:22 +08:00
parent b978071f94
commit 3d1de913f8
27 changed files with 184 additions and 307 deletions

View File

@@ -104,8 +104,12 @@ app.directive("tooltip", Tooltip);
*/
async function enableMocking() {
if (import.meta.env.VITE_MSW !== "true") return;
const { http, HttpResponse } = await import("msw");
const { worker } = await import("./mocks/browser.js");
await worker.start({ onUnhandledRequest: "bypass" });
// Expose on window so Cypress can add per-test overrides
window.__mswWorker__ = worker;
window.__msw__ = { http, HttpResponse };
}
enableMocking().then(() => app.mount("#app"));