diff --git a/src/Umbraco.Web.UI.Client/src/index.ts b/src/Umbraco.Web.UI.Client/src/index.ts index 78304be933..b0816c5567 100644 --- a/src/Umbraco.Web.UI.Client/src/index.ts +++ b/src/Umbraco.Web.UI.Client/src/index.ts @@ -1,5 +1,5 @@ import 'element-internals-polyfill'; -import { worker } from './mocks/browser'; +import { startMockServiceWorker } from './mocks/browser'; import { UmbExtensionRegistry, UmbExtensionManifest, UmbExtensionManifestCore } from './core/extension'; const extensionRegistry = new UmbExtensionRegistry(); @@ -153,14 +153,5 @@ const setup = async () => { await import('./app'); }; -worker.start({ - onUnhandledRequest: (req) => { - if (req.url.pathname.startsWith('/node_modules/')) return; - if (req.url.pathname.startsWith('/src/')) return; - if (req.destination === 'image') return; - - console.warn('Found an unhandled %s request to %s', req.method, req.url.href); - }, -}); - -setup(); +startMockServiceWorker(); +setup(); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/mocks/browser.ts b/src/Umbraco.Web.UI.Client/src/mocks/browser.ts index 750e031c2b..cc72eef4e9 100644 --- a/src/Umbraco.Web.UI.Client/src/mocks/browser.ts +++ b/src/Umbraco.Web.UI.Client/src/mocks/browser.ts @@ -1,4 +1,14 @@ import { setupWorker } from 'msw'; import { handlers } from './handlers'; -export const worker = setupWorker(...handlers); +const worker = setupWorker(...handlers); + +export const startMockServiceWorker = () => worker.start({ + onUnhandledRequest: (req) => { + if (req.url.pathname.startsWith('/node_modules/')) return; + if (req.url.pathname.startsWith('/src/')) return; + if (req.destination === 'image') return; + + console.warn('Found an unhandled %s request to %s', req.method, req.url.href); + }, +}); \ No newline at end of file