question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assert "mockServiceWorker" integrity

See original GitHub issue

Motivation

The library must assert the integrity of the mockServiceWorker.js file for multiple reasons:

  • Ensure the file is up-to-date, as it lives in the user’s public directory and is not updated during new installations of msw package
  • Ensure the file is actually a valid MSW file, to prevent malware masking as MSW

Implementation

Publication

  1. Minimize
  2. Remove comments
  3. Generate a checksum out of the mockServiceWorker.js file content

Client-side

  1. Signal to Service Worker upon start() invocation to get the integrity information.
  2. Assert the integrity on the client-side.
  3. Display an error in case integrity fails. Suggest to run npx init <PUBLIC_DIR> to resolve the issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
kentcdoddscommented, Mar 30, 2020

Excellent. Thank you!

1reaction
kentcdoddscommented, Mar 28, 2020

Oh, I was confused. So it’s not likely that there would be a problem because that file doesn’t get updates very often.

I think that’s ok. Sorry for my misunderstanding, thank you for taking the time to explain it to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Request assertions - Recipes - Mock Service Worker Docs
Include any necessary validation and utilize conditional mocking to reflect a request's integrity in your response resolvers.
Read more >
Mock Service Worker - mockServiceWorker not listening ...
I have tried to running mockserviceworker in angular prod and dev build . i have kept debugger in self.addEventListener('message') , compiler ...
Read more >
When should I (not) use mocks in testing? - DEV Community ‍ ‍
To assert a list of user's purchases you can mock the user already being authenticated, instead of going through the authentication in the ......
Read more >
A Comprehensive Guide to Mock Service Worker (MSW)
Discover our comprehensive guide to Mock Service Worker (MSW) and use the API mocking tool for testing, development, debugging to deliver ...
Read more >
Want to increase your quality and reduce your deployment ...
However, if you use Mock Service Worker to mock the endpoints, ... Mock Service Worker, render the app, and write out the assertions...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found