vendredi 29 mai 2015

Jest, Jasmine mock window.require

I'm using React and writing some tests using Jest. So since this is an Electron app, in one of my react components I do have:

var remote = window.require('remote');
var shell = remote.require('shell');

Because of the above, the tests are failing with Object [object global] has no method 'require'. So I'm trying to find a way to mock window.request. I thought that something like the code below would mock it but it does not. Any ideas?

var window = function () { return { require: function () { return {}; } }; };

module.exports = window;

Aucun commentaire:

Enregistrer un commentaire