Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generate mocks for Electron APIs (ipcMain, ipcRenderer, dialog, etc.) for unit testing
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-11 | ✗→✓ | ▲ Improved | -33% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 3% | 0% |
| case-17 | ✗→✓ | ▲ Improved | -3% | 0% |
| case-01 | ✓→✓ | = Same ✓ | -5% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 9% | 0% |
Generate mocks for Electron APIs to enable unit testing of main and renderer process code without running Electron.
json{ "type": "object", "properties": { "projectPath": { "type": "string" }, "testFramework": { "enum": ["jest", "vitest", "mocha"] }, "modulesToMock": { "type": "array" } }, "required": ["projectPath"] }
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() } })) };
javascriptjest.mock('electron'); const { ipcRenderer } = require('electron'); test('sends message', () => { myModule.sendMessage('hello'); expect(ipcRenderer.send).toHaveBeenCalledWith('channel', 'hello'); });
playwright-electron-configdesktop-unit-testing processOther measured skills in the registry, with their headline benchmark lift.