Add conditional MSW browser worker startup for E2E testing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
12
src/main.ts
12
src/main.ts
@@ -98,4 +98,14 @@ app.component("ContextMenu", ContextMenu);
|
||||
app.component("Draggable", draggable); // Drag and drop
|
||||
app.directive("tooltip", Tooltip);
|
||||
|
||||
app.mount("#app");
|
||||
/**
|
||||
* Starts the MSW service worker when VITE_MSW is set.
|
||||
* Used for E2E testing with mock API responses.
|
||||
*/
|
||||
async function enableMocking() {
|
||||
if (import.meta.env.VITE_MSW !== "true") return;
|
||||
const { worker } = await import("./mocks/browser.js");
|
||||
await worker.start({ onUnhandledRequest: "bypass" });
|
||||
}
|
||||
|
||||
enableMocking().then(() => app.mount("#app"));
|
||||
|
||||
Reference in New Issue
Block a user