electron-test-utils eslint travis-ci npm

Test Utilities to help with Electron App Testing

3 years after

Electron Test Utils

Build Status npm version npm license status

What is it?

Electron test utils is a small utility to help test Electron apps that depend on currently untestable native desktop interactions. For instance the "dialog" module currently makes your code untestable if you use it.

How do I use it?

npm i --save-dev electron-test-utils

It's really easy to use and integrates nicely into most test suites.

Your tests need access to the Electron API's, the easiest way to achieve this is to use electron-mocha

import { initialize, reset, utils } from 'electron-test-utils';

describe('my wonderful test suite', () => {
  before(() => {
    initialize();
  });

  it('should open a file after prompting the user', () => {
    utils.dialog.nextOpenDialogCall(['path/to/file']);
    // If this function requires openDialog it will be given ['path/to/file']
    const file = myOpenFileFn();
    file.should.be.equal('file_content');
  });

  afterEach(() => {
    reset();
  });
});

Note the two magic functions we call:

  • initialize() hooks into Electron to make our API's work.
  • reset() resets all return values and call values so that you get a clean slate during each test.

So what can it do?

Currently we only support the following API's. Check out our module docs below.

Related Repositories

electron-panel

electron-panel

Manipulate panels in window for Electron. ...

electron-tap

electron-tap

Electron app testing using tape ...

awesome-redux

awesome-redux

Awesome list of Redux examples and middlewares ...

angular2-seed-advanced

angular2-seed-advanced

An advanced Angular2 seed project with support for ngrx/store, ng2-translate, an ...

angular2-seed-advanced

angular2-seed-advanced

An advanced Angular2 seed project with support for ngrx/store, ng2-translate, an ...


Top Contributors

MarshallOfSound

Releases

-   v0.2.2 zip tar
-   v0.2.1 zip tar
-   v0.2.0 zip tar
-   v0.1.0 zip tar
-   v0.0.1 zip tar