skills/skills/test-factory-patterns/SKILL.md
This skill provides guidance for writing test factories in the Packmind codebase. It should be used when creating or updating factory functions in `**/test/*Factory.ts` files to ensure realistic test data with variety.
npx skillsauth add cteyton/packmind test-factory-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Test factories create realistic test data with variety. Good factories generate multiple plausible instances and randomly select one, while allowing partial overrides. Poor factories return identical static data every time.
A well-designed factory:
randomIn() to select one instance randomlyimport { Factory, randomIn } from '@packmind/test-utils';
import { Entity, createEntityId } from '@packmind/types';
import { v4 as uuidv4 } from 'uuid';
export const entityFactory: Factory<Entity> = (entity?: Partial<Entity>) => {
const entities: Entity[] = [
{
id: createEntityId(uuidv4()),
name: 'Meaningful Name One',
slug: 'meaningful-name-one',
content: `Realistic content that represents actual usage...`,
// ... other fields with realistic values
},
{
id: createEntityId(uuidv4()),
name: 'Different Meaningful Name',
slug: 'different-meaningful-name',
content: `Different realistic content...`,
// ... other fields with different realistic values
},
// Add 3-5 varied instances
];
return {
...randomIn(entities),
...entity,
};
};
Avoid factories that return identical static data:
// BAD: Always returns the same data
export const entityFactory: Factory<Entity> = (entity?: Partial<Entity>) => {
return {
id: createEntityId(uuidv4()),
name: 'Test Entity', // Static, meaningless
content: 'test content', // Not realistic
...entity,
};
};
import { Factory, randomIn } from '@packmind/test-utils';
createXxxId(uuidv4())...entitytools
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
tools
Complete automated onboarding: analyzes codebase, creates package, and generates standards & commands via CLI. Automatic package creation when none exist, user selection when packages are available.
tools
Guide for creating coding standards via the Packmind CLI. This skill should be used when users want to create a new coding standard (or add rules to an existing standard) that captures team conventions, best practices, or coding guidelines for distribution to Claude.
tools
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.