electron-mock-factory
SolidGenerate mocks for Electron APIs (ipcMain, ipcRenderer, dialog, etc.) for unit testing
Testing & QA 814 stars
53 forks Updated today MIT
Install
Quality Score: 93/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# 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('hel...
Details
- Author
- a5c-ai
- Repository
- a5c-ai/babysitter
- Created
- 4 months ago
- Last Updated
- today
- Language
- JavaScript
- License
- MIT
Integrates with
Related Skills
Testing & QA Featured
rtk-tdd
Enforces TDD (Red-Green-Refactor) for Rust development. Auto-triggers on implementation, testing, refactoring, and bug fixing tasks. Provides Rust-idiomatic testing patterns with anyhow/thiserror, cfg(test), and Arrange-Act-Assert workflow.
55,551 Updated today
rtk-ai Testing & QA Featured
tdd-rust
TDD workflow for RTK filter development. Red-Green-Refactor with Rust idioms. Real fixtures, token savings assertions, snapshot tests with insta. Auto-triggers on new filter implementation.
55,551 Updated today
rtk-ai Testing & QA Featured
wordpress-penetration-testing
Assess WordPress installations for common vulnerabilities and WordPress 7.0 attack surfaces.
38,979 Updated today
sickn33