Use when a service worker needs lifecycle tests, users are stuck on an old version after deploy, or caching and offline behavior is untested. Tests each state change from installing to activated, waitUntil, skipWaiting and clients.claim, update() and a clean v1 to v2 upgrade with Playwright.
92%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Companion detail for service-worker-lifecycle-tests: the coverage
matrix, and where the upgrade-path test lives.
tests/sw-lifecycle-coverage.yaml maps each spec to its state-machine cell.
CI gates on every matrix row having at least one passing test.
# tests/sw-lifecycle-coverage.yaml
matrix:
fresh_install:
test: "first install reaches activated"
states: [installing, installed, activating, activated]
ref: sw-spec ServiceWorkerState enum
waituntil:
test: "waitUntil holds the install phase"
states: [installing]
ref: mdn-sw waitUntil
upgrade:
test: "v1 to v2: skipWaiting + claim flip the controller and clean caches"
states: [installed, activating, activated, redundant]
events: [updatefound, statechange]
ref: mdn-skipwaiting, mdn-claim
# add when the worker omits a call (SKILL.md Steps 4-5):
# waiting_without_skipwaiting, uncontrolled_without_claimThe upgrade test is the third test in SKILL.md Step 3, run against the
fixture server in test-fixtures.md. It covers
updatefound, v1 activated → redundant, the controller switching to
v2 (skipWaiting + clients.claim), and v2's activate handler
deleting every cache except app-v2. Steps 4-5 give the expectations
for workers that skip one of the two calls.
Source references: