Skip to content

Commit

Permalink
fix(loader.ts): fix possible undefined (#141)
Browse files Browse the repository at this point in the history
If msw is running in fallback mode, navigator.serviceWorker may not be defined.
  • Loading branch information
AlexMunoz committed Mar 6, 2024
1 parent 7ca8425 commit 7f91bea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/msw-addon/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const mswLoader = async (context: Context) => {
if (
typeof window !== 'undefined' &&
'navigator' in window &&
navigator.serviceWorker.controller
navigator.serviceWorker?.controller
) {
// No need to rely on the MSW Promise exactly
// since only 1 worker can control 1 scope at a time.
Expand Down

0 comments on commit 7f91bea

Please sign in to comment.