vendredi 1 avril 2016

how to unit test components in main process of an electron app?

I have an electron app with the following folder structure:

app/js/
     |_ main.js
     |_ myClipboard.js
     |_ view/ 
         |_ render.js

Now main.js calls myClipboard to store some user data locally using nedb (document store). I want to test the logic in myClipboard since it will involve some conditional logic.

What makes this difficult is myClipboard requires the clipboard module provided by electron. The following line fails in a test setup (jasmine-node):

var clipboard=require('clipboard')

It says it couldn't find 'clipboard' module. I guess the test needs to be run from inside electron.

How do I test this?

I tried using electron-mocha, but it seems to have problems with async module that nedb uses. None of the calls like insert, update, etc work in test environment, but they work fine when I bring up my app.

Am I missing anything here?

Aucun commentaire:

Enregistrer un commentaire