Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jsantell/electron-ipc-mock
Mock channels for Electron's IPC communication
https://github.com/jsantell/electron-ipc-mock
Last synced: 3 months ago
JSON representation
Mock channels for Electron's IPC communication
- Host: GitHub
- URL: https://github.com/jsantell/electron-ipc-mock
- Owner: jsantell
- License: mit
- Created: 2016-04-20T22:30:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-04T22:45:47.000Z (over 7 years ago)
- Last Synced: 2024-11-01T00:51:28.306Z (3 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 14
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
electron-ipc-mock
=======[![Build Status](http://img.shields.io/travis/jsantell/electron-ipc-mock.svg?style=flat-square)](https://travis-ci.org/jsantell/electron-ipc-mock)
[![Build Status](http://img.shields.io/npm/v/electron-ipc-mock.svg?style=flat-square)](https://www.npmjs.org/package/electron-ipc-mock)Mock Communication for Electron's IPC
An API mimicking [Electron's](http://electron.atom.io/docs/latest/api/ipc-renderer/) [ipcMain](http://electron.atom.io/docs/latest/api/ipc-main/) and [ipcRenderer](http://electron.atom.io/docs/latest/api/ipc-renderer/). Swap out electron calls in your code in tests to access both mock renderer and main process IPC communication calls.
## Install
```
npm install electron-ipc-mock
```## Usage
```js
const { ipcRenderer, ipcMain } = require('electron-ipc-mock')();ipcMain.on('request', function (e, ...args) {
console.log(args[0]); // 'hello'
e.sender.send('response', 'world');
});ipcRenderer.on('response', function (e, ...args) {
console.log(args[0]); // 'world'
});ipcRenderer.send('request', 'hello')
```## Testing
```
npm test
```## License
MIT License, Copyright (c) 2016 Jordan Santell