File watching does not execute actual code changes when site under test utilizes Service Workers.
See original GitHub issueRelated to #686.
It’s possible the application under test ends up using Server Workers to inadvertently cache the files Cypress uses to serve spec files. This prevents changes to the spec files from ever being updated.
Prior to the beginning of all tests we should clear the Service Worker cache and then add a new cy command and add this to lifecycle rules cy.clearServiceWorkerCache().
We could make this command print out all the cache keys it cleared.
Workaround:
before(function () {
  // run this once before all code
  return window.caches.keys().then(function(cacheNames) {
    return Promise.all(
      cacheNames.map(function(cacheName) {
        return window.caches.delete(cacheName);
      })
    );
  })
})
Issue Analytics
- State:
 - Created 6 years ago
 - Reactions:20
 - Comments:33 (6 by maintainers)
 
Top Results From Across the Web
File watching does not execute actual code changes when ...
Within Chrome, go into DevTools > Application > Service Workers and click Unregister . Add the code below for every visit to the...
Read more >Introduction - Mock Service Worker Docs
Mock Service Worker is an API mocking library that uses Service Worker API to intercept actual requests.
Read more >Create a Customizable FileSystemWatcher Windows Service
This class is able to detect events in the file system, such as create, modify, or delete files and folders; it's fully customizable;...
Read more >linux - How to execute a command whenever a file changes?
Simple, using inotifywait (install your distribution's inotify-tools package): while inotifywait -e close_write myfile.py; do ./myfile.py; done.
Read more >Services overview | Android Developers
A service is simply a component that can run in the background, even when the user is not interacting with your application, so...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@mackelito I’ve managed to unregister all service workers before each test in one of my specs like this:
We need to make a decision here. Currently ServiceWorkers end up generating very confusing behavior in Cypress which is hard for new (and even old) users to debug.
Proposal
enableServiceWorkers: falseby default (?)When we enable lifecycle events this could potentially conflict…