Mocking strategies

From vladkesler/initrunner · View interactive version

Mocking strategies is an AI agent skill from the GitHub repository vladkesler/initrunner. Mock, patch, fake, and stub patterns for isolating dependencies in Python and JavaScript test suites.

How to use this skill

Skill file

Mocking strategies for isolating external dependencies in tests.

When to activate

Use this skill when tests need to isolate external dependencies such as

databases, APIs, filesystems, time, or randomness.

Python mocking

the duration of a test. Use as a decorator or context manager.

object.

API; accessing non-existent attributes raises AttributeError.

exception class to simulate errors.

or dict items for the duration of a test without import-path gymnastics.

JavaScript mocking

module. Provide a factory function for custom behavior.

the real module to override it project-wide.

arguments to make them trivially replaceable in tests.

realistic API mocking without changing application code.

When to mock

When NOT to mock

Mock verification

mock.call_count, mock.call_args_list.

expect(fn).toHaveBeenCalledWith(arg1, arg2).

MUST

not where it is defined.

exist on the real object.

MUST NOT

and proves nothing about real behavior.

mocking open is fine for filesystem isolation, but mocking len is

not).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.