Skip to content

Commit

Permalink
test(find-worker): return error.message for worker start errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Oct 13, 2024
1 parent c30595c commit 1ee12ba
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/browser/msw-api/setup-worker/start/find-worker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ test('resolves the "start" Promise and returns a ServiceWorkerRegistration when

expect(resolvedPayload).toBe('ServiceWorkerRegistration')

const activationMessageIndex = consoleSpy
.get('startGroupCollapsed')
?.findIndex((text) => {
const activationMessageIndex =
consoleSpy.get('startGroupCollapsed')?.findIndex((text) => {
return text.includes('[MSW] Mocking enabled')
})
}) ?? -1

const customMessageIndex = consoleSpy.get('log').findIndex((text) => {
return text.includes('Registration Promise resolved')
})
const customMessageIndex =
consoleSpy.get('log')?.findIndex((text) => {
return text.includes('Registration Promise resolved')
}) ?? -1

expect(activationMessageIndex).toBeGreaterThan(-1)
expect(customMessageIndex).toBeGreaterThan(-1)
Expand All @@ -55,7 +55,7 @@ test('fails to return a ServiceWorkerRegistration when using a findWorker that r
})

const workerStartError = await page.evaluate(() => {
return window.msw.registration.catch((err) => err)
return window.msw.registration.catch((error) => error.message)
})

const activationMessage = consoleSpy
Expand All @@ -64,7 +64,7 @@ test('fails to return a ServiceWorkerRegistration when using a findWorker that r
return text.includes('[MSW] Mocking enabled')
})

const errorMessageIndex = consoleSpy.get('error').findIndex((text) => {
const errorMessageIndex = consoleSpy.get('error')?.findIndex((text) => {
return text.includes('Error - no worker instance after starting')
})

Expand Down

0 comments on commit 1ee12ba

Please sign in to comment.