nullables-testing-style

Guide developers in writing state-based tests using Nullables construction patterns.

Updated Apr 24, 2025
One-click install
npx skills add https://github.com/danielbush/oneput --skill nullables-testing-style
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nullables-testing-style
Source: https://github.com/danielbush/oneput/tree/main/.agents/skills/nullables-testing-style
Command: npx skills add https://github.com/danielbush/oneput --skill nullables-testing-style

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Use this skill when refactoring code or writing tests in the Nullables style. It guides you to choose between new, .create(), and .createNull(), introduces infrastructure wrappers at the environment boundary, adds behavior simulation and output tracking, and encourages narrow, sociable, example-driven, state-based tests without mocks or spies.

Core Features & Use Cases

  • Clear construction rules: prefer new for the class under test and .createNull() for dependencies.
  • Infrastructure wrappers at the environment boundary to isolate I/O and provide configurable responses.
  • Behavior simulation to model external events without hitting real environments.
  • Output tracking to verify observable changes instead of spying on internal calls.
  • Example-driven, state-based tests that are easy to read and reason about.

Quick Start

Create a test using new for the class under test, wire dependencies with .createNull() for nulled environments, add a minimal infrastructure wrapper, and write a short state-based example.

Frequently Asked Questions about nullables-testing-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write state-based tests in TypeScript without using mocks?

To write state-based tests without mocks, use the Nullables style by instantiating classes with `new`, wiring dependencies via `.createNull()`, and verifying observable output through output tracking instead of spying on internal calls.

What is the Nullables testing pattern and when should I use it?

The Nullables testing pattern is an approach that uses infrastructure wrappers and configurable null dependencies to isolate I/O. Use it when refactoring code or creating sociable, example-driven tests to avoid mocks and simulate environment-bound behavior safely.

How do I configure null dependencies for infrastructure wrappers in TypeScript tests?

Configure null dependencies by implementing `.create()` and `.createNull()` factory methods on your infrastructure wrappers. This provides configurable responses for external events and isolates the class under test from real I/O environments during testing.

How do I verify external event behavior without spies in TypeScript unit tests?

Verify external event behavior without spies by using behavior simulation within infrastructure wrappers and output tracking. This mechanism records observable changes and state transitions, allowing you to assert results directly rather than inspecting mock interactions.

What is the best way to refactor TypeScript code to remove mock dependencies?

The best way to remove mock dependencies is introducing infrastructure wrappers at the environment boundary. Replace mock setups with explicit instances and `.createNull()` methods, enabling state-based tests that are easier to read and reason about.

When should I not use the Nullables testing style for TypeScript refactoring?

Avoid the Nullables testing style when you cannot modify the environment boundary to introduce infrastructure wrappers, or when your codebase strictly requires traditional mock frameworks to verify internal function calls rather than observable state.