electron-mock-factory

Generate mocks for Electron APIs (ipcMain, ipcRenderer, dialog, etc.) for unit testing

509 stars

Best use case

electron-mock-factory is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Generate mocks for Electron APIs (ipcMain, ipcRenderer, dialog, etc.) for unit testing

Teams using electron-mock-factory should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/electron-mock-factory/SKILL.md --create-dirs "https://raw.githubusercontent.com/a5c-ai/babysitter/main/library/specializations/desktop-development/skills/electron-mock-factory/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/electron-mock-factory/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How electron-mock-factory Compares

Feature / Agentelectron-mock-factoryStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Generate mocks for Electron APIs (ipcMain, ipcRenderer, dialog, etc.) for unit testing

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# electron-mock-factory

Generate mocks for Electron APIs to enable unit testing of main and renderer process code without running Electron.

## Capabilities

- Mock ipcMain/ipcRenderer
- Mock dialog module
- Mock BrowserWindow
- Mock shell, clipboard, app
- Generate Jest/Vitest mocks
- Create test utilities

## Input Schema

```json
{
  "type": "object",
  "properties": {
    "projectPath": { "type": "string" },
    "testFramework": { "enum": ["jest", "vitest", "mocha"] },
    "modulesToMock": { "type": "array" }
  },
  "required": ["projectPath"]
}
```

## Generated Mocks

```javascript
// __mocks__/electron.js
module.exports = {
  app: {
    getPath: jest.fn(name => `/mock/${name}`),
    getVersion: jest.fn(() => '1.0.0'),
    quit: jest.fn(),
    on: jest.fn()
  },
  ipcMain: {
    on: jest.fn(),
    handle: jest.fn(),
    removeHandler: jest.fn()
  },
  ipcRenderer: {
    on: jest.fn(),
    send: jest.fn(),
    invoke: jest.fn()
  },
  dialog: {
    showOpenDialog: jest.fn(() => Promise.resolve({ filePaths: [] })),
    showSaveDialog: jest.fn(() => Promise.resolve({ filePath: undefined })),
    showMessageBox: jest.fn(() => Promise.resolve({ response: 0 }))
  },
  BrowserWindow: jest.fn().mockImplementation(() => ({
    loadURL: jest.fn(),
    on: jest.fn(),
    webContents: { send: jest.fn(), on: jest.fn() }
  }))
};
```

## Usage

```javascript
jest.mock('electron');
const { ipcRenderer } = require('electron');

test('sends message', () => {
  myModule.sendMessage('hello');
  expect(ipcRenderer.send).toHaveBeenCalledWith('channel', 'hello');
});
```

## Related Skills

- `playwright-electron-config`
- `desktop-unit-testing` process

Related Skills

mock-spec-extractor

509
from a5c-ai/babysitter

Extracts design specifications from mock images including colors, typography, spacing, and component details

api-mock-server

509
from a5c-ai/babysitter

Generate and run mock API servers from OpenAPI specifications

sdk-mock-generator

509
from a5c-ai/babysitter

Generate mock servers and clients for SDK testing

playwright-electron-config

509
from a5c-ai/babysitter

Configure Playwright for comprehensive Electron application testing including E2E tests, visual regression, accessibility audits, and cross-platform test matrices

electron-tray-menu-builder

509
from a5c-ai/babysitter

Generate system tray and context menu configurations with platform-specific icons, menu templates, and event handling

electron-protocol-handler-setup

509
from a5c-ai/babysitter

Register and handle custom URL protocols (deep linking) across platforms for Electron applications

electron-native-addon-builder

509
from a5c-ai/babysitter

Build and bundle native Node.js addons for Electron with proper ABI compatibility, cross-compilation support, and rebuild automation

electron-memory-profiler

509
from a5c-ai/babysitter

Profile Electron app memory usage, detect leaks, analyze renderer process memory, and optimize memory consumption

electron-main-preload-generator

509
from a5c-ai/babysitter

Generate secure main process and preload script boilerplate with proper context isolation, IPC patterns, and security best practices for Electron applications

electron-ipc-security-audit

509
from a5c-ai/babysitter

Analyze Electron IPC implementations for security vulnerabilities including contextIsolation, nodeIntegration, preload scripts, and channel validation

electron-builder-config

509
from a5c-ai/babysitter

Generate and validate electron-builder configuration for multi-platform desktop builds with code signing, auto-update, and platform-specific packaging

electron-auto-updater-setup

509
from a5c-ai/babysitter

Configure electron-updater with code signing verification, delta updates, staged rollouts, and multiple update channels for Electron applications