Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

offline-fallback-tests

БесплатноБез исполняемых скриптовНе проверен

Use when choosing or changing how a PWA route behaves offline, or a 'doesn't work offline' bug needs pinning to a route. Maps each route to an offline caching…

testlandот testland★ 18 звёзд на GitHub

Об этом скилле

offline-fallback-tests

Overview

Offline behavior fragments into eight named recipes per Jake Archibald's offline cookbook off-cookbook - and most PWAs use three or four of them across different routes. A test suite that asserts "the site works offline" misses the per-route recipe contract: a route on Cache only must serve from cache even when network is fine; a route on Network falling back to cache must prefer network when both are present.

This skill emits the per-route test suite. The output is a Playwright spec file plus a coverage YAML that maps each URL pattern to its recipe and its assertion. The suite is distinct from the strategy authoring covered by workbox-tests (references/cache-strategy-design.md); that side authors the strategy, this builder generates the verification.

Composes with:

  • workbox-tests - when the SW uses Workbox's offlineFallback() recipe, the workbox-tests spec covers the recipe's runtime; this builder covers the per-route decision and the page-side assertion.
  • service-worker-lifecycle-tests - every recipe assumes an active SW; the lifecycle spec is the prerequisite for this one.
  • add-to-homescreen-flow-tests (references/install-flow-reference.md) - install-gate Stage 1's service-worker prerequisite cell is the same SW this builder tests offline behavior of.

When to use

  • New PWA - author the offline-fallback test plan before any route ships SW caching.
  • "Site doesn't work offline" bug report - the recipe matrix localizes whether the recipe is wrong or just missing for that route.
  • Migrating from hand-rolled caches.match / event.respondWith to Workbox offlineFallback() - assert that the recipe-named behavior matches the hand-rolled one.
  • Adding a new offline-capable feature (e.g. saved articles, draft form data) - pick a recipe per the matrix and emit the test.

Workflow

Step 1 - Inventory routes and pick a recipe per route

For each URL pattern the SW intercepts, decide which of the eight named recipes per off-cookbook applies. The cookbook recipes verbatim:

Recipe (per off-cookbook) When to use (quoted)
Cache only "Use for static assets you've cached during installation that your site depends on."
Network only "Best for requests without offline equivalents, like analytics or non-GET operations."
Cache, falling back to network "Ideal for building offline-first apps where cached content serves as the default."
Cache and network race "Useful when disk access is slow and network speed might win the competition for small assets."
Network falling back to cache "Good for frequently updating resources, though slow connections create user frustration."
Cache then network "Perfect for content that changes often; displays cached data immediately, updates when fresh data arrives."
Generic fallback "Provides a default response when both cache and network requests fail for secondary content."
Service worker-side templating "Combines cached templates with JSON data to render pages the service worker controls."

Workbox layers a named composite recipe on top per wb-recipes:

  • offlineFallback() - "serve a web page, image, or font if there's a routing error" when users are offline, defaulting to offline.html.

Capture decisions in a YAML manifest:

# tests/offline-recipe-matrix.yaml
routes:
  - pattern: /_next/static/**
    recipe: Cache only
    reason: Hashed filenames, immutable
  - pattern: /
    recipe: Network falling back to cache
    reason: HTML shell - fresh while online, stale offline
  - pattern: /api/feed
    recipe: Cache then network
    reason: List view; show fast, update behind
  - pattern: /api/user/me
    recipe: Network only
    reason: PII; never cache
  - pattern: /img/**
    recipe: Cache, falling back to network
    reason: Bandwidth save; image lifetime ≥ cache TTL
  - pattern: /*
    recipe: Generic fallback
    reason: Catch-all 404; offline.html

Step 2 - Emit the per-recipe Playwright test

For each recipe row in Step 1's matrix, emit the matching test - the assertion shape must distinguish "served from cache" vs "served from network." The two poles (cache-always vs network-always) are inline; the rest live in the reference.

Cache only

Serves from cache even with network reachable AND with network blocked:

test('Cache only: /_next/static/x.css serves from cache regardless of network', async ({ page, context }) => {
  await page.goto('https://localhost:3000/');
  await page.waitForLoadState('networkidle');

  // Block network for the static path
  await context.route('**/_next/static/**', route => route.abort('failed'));

  const res = await page.evaluate(() =>
Полный SKILL.md на GitHub

Установить offline-fallback-tests в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.tessl-plugin/plugin.jsonreferences/recipes.md

FAQ

Что делает скилл offline-fallback-tests?

Use when choosing or changing how a PWA route behaves offline, or a 'doesn't work offline' bug needs pinning to a route. Maps each route to an offline caching recipe (cache first, network first and others), tests it with Playwright, and covers Workbox offlineFallback and storage choices.

Как установить скилл offline-fallback-tests?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл offline-fallback-tests запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить offline-fallback-tests с