← ClaudeAtlas

test-datalisted

Create isolated, throwaway test data for automated tests (or manual dev runs) and clean it up afterward. Use when a test or a local experiment needs rounds, games, sessions, or votes to run against, and you must NOT touch the real data/ folder. Covers the temp-DATA_DIR pattern, seeding via the API vs. a raw data.json, and teardown.
ChulioZ/spielwirbel · ★ 0 · Data & Documents · score 56
Install: claude install-skill ChulioZ/spielwirbel
# Create & tear down test data The production `data/` folder is **strictly off-limits** to read or write — it is private user data (see `.claude/rules/no-reading-production-data.md`). So never copy, edit, or point tests at the real file. Instead, spin up an **isolated dataset in a temp folder** via `DATA_DIR`, fill it with data you generate, and throw the whole folder away afterward. ## The one rule that makes this work: set `DATA_DIR` first `lib/store.js` reads `data.json` into memory **once at require-time** and keeps it there. So the isolation only holds if `process.env.DATA_DIR` points at your temp folder **before** the first `require('../lib/store')` (which happens transitively through `require('../lib/app')`). Set it too late and you get the real `data/` or an already-cached copy. See `.claude/rules/automated-tests.md`. `node --test` runs **each test file in its own process**, so every file gets a fresh, empty dataset and there is no cross-file bleed. ## For automated tests: use `test/helpers.js` `test/helpers.js` already does the temp-folder dance in the right order and exports a ready `app`, the `store`, the temp `DATA_DIR`, and a `createRound` helper. Require it **first** in a test file — do not require `lib/app` or `lib/store` above it. ```js const { app, store, createRound } = require('./helpers'); const request = require('supertest'); // drives the app in-process, opens no port ``` ### Prefer seeding through the API Build data the same way the app does, s