spread-real-module-exports-as-base-of-every-mock-module-return-o

Spread real module exports into every mock.module return object.

437|45|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/ZaxbyHub/opencode-swarm --skill spread-real-module-exports-as-base-of-every-mock-module-return-o
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spread-real-module-exports-as-base-of-every-mock-module-return-o
Source: https://github.com/ZaxbyHub/opencode-swarm/tree/main/.opencode/skills/generated/spread-real-module-exports-as-base-of-every-mock-module-return-o
Command: npx skills add https://github.com/ZaxbyHub/opencode-swarm --skill spread-real-module-exports-as-base-of-every-mock-module-return-o

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When using Node.js's built-in mock.module functionality, default mock return objects do not include the real module's exports, leading to missing properties, incorrect mock behavior, and test failures that do not reflect actual module behavior.

Core Features & Use Cases

  • Enforces spreading real module exports as the base of every mock.module return object to align mock behavior with actual module interfaces.
  • Includes automated reviewer checks to grep for mock.module patterns that lack the required real module spread, catching inconsistent mocks early in the development workflow.
  • Use Case: When writing unit tests for a Node.js utility module, apply this skill to ensure all mock.module return objects include the utility's real exports, avoiding test failures from missing mock properties.

Quick Start

Apply this skill when writing Node.js unit tests to ensure all mock.module return objects spread the real module's exports as their base.

Frequently Asked Questions about spread-real-module-exports-as-base-of-every-mock-module-return-o

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

FAQPage Schema
Why do my Node.js mock.module tests fail with missing properties?

Node.js mock.module tests fail when default mock return objects exclude real module exports. Spreading real module exports as the base of every mock return object aligns mock behavior with actual interfaces and restores missing properties.

How do I spread real module exports in a mock.module return object?

To spread real module exports in a mock.module return object, apply the spread operator to the real module's exports as the base before overriding specific properties, ensuring the mock maintains the actual module interface.

What is the best way to enforce consistent mock.module patterns in Node.js testing?

The best way to enforce consistent mock.module patterns is to use automated grep checks that validate every mock.module return object includes the required real module spread, catching missing patterns early in development.

Can I use this mock module pattern for Node.js integration tests?

Yes, you can use this pattern for Node.js integration tests. Spreading real module exports as the base of mock.module return objects ensures mock behavior reflects actual module interfaces across both unit and integration test scenarios.

When do I need to spread real exports in Node.js mock modules?

You need to spread real exports in Node.js mock modules whenever you use the built-in mock.module functionality to create mocks, as default return objects lack real exports and cause incorrect mock behavior.