Verify that a game's saves persist and recover. Progress and settings survive reloads, and the game never crashes on missing, corrupt, wrong-type, future-version, huge or old-version save data, blocked storage (private mode, embeds) or a full quota. Automated scenarios, plus migration tests in node and a manual checklist (reset, multiple tabs, cloud and Bash user data). Use after changing anyth...
Download skill (.zip) Files on GitHubGame save testing
Automated scenarios (2D / DOM games)
python3 <skill>/scripts/save-test.py http://localhost:8000/ --play "Enter,ArrowRight,Escape"
python3 <skill>/scripts/save-test.py http://localhost:8000/ --keys mygame:v1:best,mygame:v1:settings
python3 <skill>/scripts/save-test.py http://localhost:8000/ --old-save tests/save-v1.json # migration from an old version
| Scenario | Passes when |
|---|---|
| persist | Keys written during --play are still there with the same values after a reload |
| empty | First-time player: no errors |
| corrupt | Save is {not json: no errors (falls back to defaults) |
| wrong-type | Save is 42, null, []: no errors |
| future-version | {"v": 999}: no crash (keep the data, use defaults, or say “save from a newer version”) |
| huge | 1 MB string: no errors |
| old-version | Your real old save loads and migrates |
| blocked | localStorage throws: the game still runs (no saving) |
| quota-full | setItem throws: the game still runs |
The persist check only sees keys written during --play. If the game saves only at game over, pass --keys or play to a
save point. Tested on a broken save module: it caught 5 failures. On the game-scaffolding template, it passes all 10.
Save code that passes
function load(key, fallback) {
try {
const raw = localStorage.getItem(key);
if (raw == null) return structuredClone(fallback);
const data = JSON.parse(raw);
if (!data || typeof data !== "object" || Array.isArray(data)) return structuredClone(fallback);
return migrate(data, fallback); // fills missing fields, upgrades old versions
} catch { return structuredClone(fallback); }
}
function store(key, value) { try { localStorage.setItem(key, JSON.stringify(value)); return true; } catch { return false; } }
Migrations: see game-save-migration. Keep a real save file from every released version in tests/ and test it in node:
migrate(v1Save) must give a valid current save with the progress preserved.
Manual checks
- Reset progress works, asks first, and really clears everything (and reloads to defaults).
- Two tabs open: the last write wins and nothing gets corrupted (or listen to the
storageevent). - Settings (volume, controls) apply immediately on load, before the first sound plays.
- itch.io: saves persist between visits on the same game page. Bash: user-specific or shared data uses the Bash SDK
(bash-js-sdk / playing-together), not
localStorage, if it must follow the player across devices.
Report
“Saves: persist across reload; survive corrupt, wrong-type, huge, blocked and full storage; v1 saves migrate to v2 with best score kept.”