← ClaudeAtlas

testing-with-nullableslisted

Guides writing fast, reliable, refactoring-friendly tests using the Nullables pattern language (James Shore's 'Testing Without Mocks'). Produces narrow, sociable, state-based tests with production code that has an infrastructure 'off switch' — no mock frameworks needed. Use when writing tests, replacing mocks with Nullables, making infrastructure code testable, adding createNull() factories, implementing output tracking, wrapping external dependencies, or adopting testing-without-mocks patterns. Covers embedded stubs, configurable responses, behavior simulation, A-Frame architecture, and incremental migration from mock-based test suites.
msewell/agent-stuff · ★ 0 · Testing & QA · score 67
Install: claude install-skill msewell/agent-stuff
# Testing With Nullables ## Core concept Nullables are production classes with an infrastructure "off switch." Each infrastructure class provides two factories: - `create()` — production instance with real I/O - `createNull()` — same class, same code paths, but I/O suppressed at the third-party boundary Tests exercise real production code. Only the lowest-level third-party calls are stubbed. ```typescript class CommandLine { private constructor(private stdout: WritableStream, private _args: string[]) {} static create(): CommandLine { return new CommandLine(process.stdout, process.argv.slice(2)); } static createNull(options?: { args?: string[] }): CommandLine { return new CommandLine(new NullWritableStream(), options?.args ?? []); } write(text: string): void { this.stdout.write(text); } args(): string[] { return this._args; } } ``` ## Workflow: Making a dependency testable with Nullables 1. **Identify the infrastructure boundary.** Find the class that talks to an external system (HTTP, file system, database, stdout). 2. **Create an Infrastructure Wrapper** if one doesn't exist. One wrapper per external system. Translate between external formats and domain types. 3. **Add an Embedded Stub.** Stub the *third-party code* (not yours) with a minimal implementation covering only the methods your code calls. Keep it in the same file. 4. **Add `createNull()`** factory that injects the embedded stub instead of the real third-party dependency. Both factor