xiaohongshu
xiaohongshu
manage-fake
Create or update Fake test doubles for TypeScript interfaces. Use when user asks to "create a fake", "update a fake", "generate test fake", "fix fake", "manage fake", or mentions needing a fake for testing. Generates Initializer interface, Fake class, and Builder class following the testing patte...
Full skill instructions
This skill helps you create or update a Fake class for testing purposes. Fakes are test doubles that implement interfaces with configurable behavior.
Use this skill when you need to:
The skill will generate/update:
Invoke this skill when the user asks to:
Before creating/updating a fake:
Fake[ClassName] filesIf fake file exists: Update mode
If fake file does NOT exist: Create mode
For an interface named IMyClass, create:
FakeMyClass.tsFakeMyClassInitializerFakeMyClassFakeMyClassBuilderPattern: Remove the I prefix from the interface name and add Fake prefix.
import { getMockingFunction } from '@zdr-tools/zdr-testing-tools';
import { FakeEntity, FakeEntityBuilder, FakesFactory, type IFakeEntityInitialData } from '@zdr-tools/zdr-entities/fakes';
import type { IEntity, IPropEventBroker, IReadablePropEventBroker, IEntityCollection, IOrderedEntityCollection, IRestorablePropEventBroker } from '@zdr-tools/zdr-entities';
Purpose: Defines all required parameters for creating the fake.
Rules:
?)[methodName]ReturnValue)Standard Pattern:
export interface FakeMyClassInitializer {
someField: string;
anotherField: number;
someMethodReturnValue: boolean;
}
If interface extends IEntity:
export interface FakeMyClassInitializer extends IFakeEntityInitialData {
someField: string;
anotherField: number;
someMethodReturnValue: boolean;
}
Purpose: The actual fake implementation of the interface.
Standard Pattern:
export class FakeMyClass implements IMyClass {
public someField: string;
public anotherField: number;
constructor(private fakeMyClassInitialData: FakeMyClassInitializer) {
this.someField = fakeMyClassInitialData.someField;
this.anotherField = fakeMyClassInitialData.anotherField;
}
someMethod = getMockingFunction<(arg: string) => boolean>(() => {
return this.fakeMyClassInitialData.someMethodReturnValue;
});
}
If interface extends IEntity:
export class FakeMyClass extends FakeEntity implements IMyClass {
public someField: string;
public anotherField: number;
constructor(private fakeMyClassInitialData: FakeMyClassInitializer) {
super(fakeMyClassInitialData);
this.someField = fakeMyClassInitialData.someField;
this.anotherField = fakeMyClassInitialData.anotherField;
}
someMethod = getMockingFunction<(arg: string) => boolean>(() => {
return this.fakeMyClassInitialData.someMethodReturnValue;
});
}
Method Implementation Rules:
getMockingFunction to wrap methods[methodName]ReturnValue field in initializerPurpose: Provides a fluent API for creating fakes with sensible defaults.
Standard Pattern:
export class FakeMyClassBuilder {
private someField: string = '';
private anotherField: number = 0;
private someMethodReturnValue: boolean = false;
withSomeField(value: string): this {
this.someField = value;
return this;
}
withAnotherField(value: number): this {
this.anotherField = value;
return this;
}
withSomeMethodReturnValue(value: boolean): this {
this.someMethodReturnValue = value;
return this;
}
protected getFakeMyClassInitializer(): FakeMyClassInitializer {
return {
someField: this.someField,
anotherField: this.anotherField,
someMethodReturnValue: this.someMethodReturnValue,
};
}
build(): FakeMyClass {
return new FakeMyClass(this.getFakeMyClassInitializer());
}
}
If interface extends IEntity:
export class FakeMyClassBuilder extends FakeEntityBuilder {
private someField: string = '';
private anotherField: number = 0;
private someMethodReturnValue: boolean = false;
withSomeField(value: string): this {
this.someField = value;
return this;
}
withAnotherField(value: number): this {
this.anotherField = value;
return this;
}
withSomeMethodReturnValue(value: boolean): this {
this.someMethodReturnValue = value;
return this;
}
protected getFakeMyClassInitializer(): FakeMyClassInitializer {
return {
...this.getInitialData(), // From FakeEntityBuilder
someField: this.someField,
anotherField: this.anotherField,
someMethodReturnValue: this.someMethodReturnValue,
};
}
build(): FakeMyClass {
return new FakeMyClass(this.getFakeMyClassInitializer());
}
}
Use these default values for different field types:
| Type | Default Value |
|---|---|
| Fields that can be undefined | undefined |
string | '' |
number | 0 |
boolean | false |
IReadablePropEventBroker<T> | FakesFactory.createReadablePropEventBroker<T>(defaultValueForT) |
IPropEventBroker<T> | FakesFactory.createPropEventBroker<T>(defaultValueForT) |
IRestorablePropEventBroker<T> | FakesFactory.createFakeRestorablePropEventBroker<T>(defaultValueForT) |
IEntityCollection<T> | FakesFactory.createEntityCollection<T>([]) |
IOrderedEntityCollection<T> | FakesFactory.createOrderedEntityCollection<T>([]) |
| Entity/Model types | new Fake[EntityName]Builder().build() |
For EventBroker fields, create TWO "with" methods:
// Field definition
private name: IPropEventBroker<string> = FakesFactory.createPropEventBroker<string>('');
// Method 1: Accept the full EventBroker
withName(value: IPropEventBroker<string>): this {
this.name = value;
return this;
}
// Method 2: Accept just the value (convenience method)
withNameValue(value: string): this {
return this.withName(FakesFactory.createPropEventBroker<string>(value));
}
IMPORTANT: All fakes MUST be organized in a /fakes folder at the package root level (sibling to /src):
packages/
my-package/
src/
IMyClass.ts # Interface definitions
MyClass.ts
fakes/ # Sibling to src, NOT inside src
index.ts # Exports all fakes
FakeMyClass.ts # Fake implementation
FakeOtherClass.ts
Fakes folder location: Always create fakes in /fakes/ at the package root (sibling to /src)
packages/my-package/src/IMyClass.tspackages/my-package/fakes/FakeMyClass.ts (NOT in src/fakes/)Index file: The /fakes folder MUST contain an index.ts file that exports all fakes
index.ts doesn't exist, create itexport * from './FakeMyClass';After creating/updating a fake: Always add/verify the export in /fakes/index.ts
// fakes/index.ts (at package root, sibling to src/)
export * from './FakeReport';
export * from './FakeUser';
export * from './FakeWorkspace';
/fakes folder exists - Check if /fakes/ directory exists at package root (sibling to /src), create if needed/fakes/FakeMyClass.ts with all three components:
/fakes/index.ts exists, create if it doesn'texport * from './FakeMyClass';with* method)[methodName]ReturnValue to initializer, add method implementation in fake class with getMockingFunction, add field and with* method to builder[methodName]ReturnValue and all related codegetMockingFunction and the return value typewith* methods, and the protected getter methodWhen updating an existing fake:
with* methodsInterface change:
export interface IReport extends IEntity {
title: string;
status: string;
description: string; // NEW FIELD
}
Required updates:
FakeReportInitializer: description: string;FakeReport class: public description: string;this.description = fakeReportInitialData.description;FakeReportBuilder: private description: string = '';withDescription(value: string): this {
this.description = value;
return this;
}
getFakeReportInitializer() return object: description: this.description,Interface change:
export interface IReport extends IEntity {
// ... existing fields
validate(): Promise<boolean>; // NEW METHOD
}
Required updates:
FakeReportInitializer: validateReturnValue: Promise<boolean>;FakeReport class:validate = getMockingFunction<() => Promise<boolean>>(() => {
return this.fakeReportInitialData.validateReturnValue;
});
FakeReportBuilder: private validateReturnValue: Promise<boolean> = Promise.resolve(false);withValidateReturnValue(value: Promise<boolean>): this {
this.validateReturnValue = value;
return this;
}
getFakeReportInitializer() return object: validateReturnValue: this.validateReturnValue,Interface change:
export interface IReport extends IEntity {
title: string;
// status: string; // REMOVED
}
Required updates:
FakeReportInitializer: status: string;FakeReport class: public status: string;this.status = fakeReportInitialData.status;FakeReportBuilder: private status: string = '';withStatus(...)getFakeReportInitializer() return object: status: this.status,Interface change:
export interface IReport extends IEntity {
title: string;
status: ReportStatus; // Changed from string to enum/type
}
Required updates:
FakeReportInitializer: status: ReportStatus;FakeReport class: public status: ReportStatus;this.status = fakeReportInitialData.status;FakeReportBuilder with appropriate default: private status: ReportStatus = ReportStatus.Draft;withStatus(value: ReportStatus): thisstatus: this.status,Interface change:
export interface IReport extends IEntity {
title: IPropEventBroker<string>; // Changed from string to EventBroker
}
Required updates:
FakeReportInitializer: title: IPropEventBroker<string>;FakeReport class: public title: IPropEventBroker<string>;this.title = fakeReportInitialData.title;FakeReportBuilder: private title: IPropEventBroker<string> = FakesFactory.createPropEventBroker<string>('');withTitle(value: IPropEventBroker<string>): this {
this.title = value;
return this;
}
withTitleValue(value: string): this {
return this.withTitle(FakesFactory.createPropEventBroker<string>(value));
}
title: this.title,See examples.md in the same directory as this skill for complete working examples.
/fakes/ directory at package root (sibling to /src, NOT inside /src)/fakes/index.tsindex.tsindex.ts alphabetically sorted for maintainability?)getMockingFunction for all method implementationsthis from builder "with" methods for chaininggetFake[ClassName]Initializer() returns the initializer objectbuild() creates the fake instance/fakes/index.ts after updatesxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience