Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using jest: ElectronStore is not a constructor #89

Closed
flaushi opened this issue Oct 16, 2019 · 1 comment
Closed

using jest: ElectronStore is not a constructor #89

flaushi opened this issue Oct 16, 2019 · 1 comment

Comments

@flaushi
Copy link

flaushi commented Oct 16, 2019

Hey, I am no pro with nodejs, I'd be grateful for some help.

I am trying to mock electron in my jest test suite, because the ElectronStore constructor calls

const defaultCwd = (electron.app || electron.remote.app).getPath('userData');

So I have a jest.config.js:

module.exports = {
    "roots": [
      "<rootDir>/src"
    ],
    "transform": {
        "^.+\\.tsx?$": "ts-jest"
    },
    "testPathIgnorePatterns" : ['mocks'],
    "moduleNameMapper": {
        "electron" : "<rootDir>/mocks/electronMock.js"
    }
  }

and the electronMock.js

module.exports = {
    app: {
        getPath: jest.fn().mockReturnValue('.')
    }
}

But I get the following error message:

TypeError: ElectronStore is not a constructor

       5 | import * as XLSX from 'xlsx';
       6 | import  ElectronStore = require('electron-store');
    >  7 | const store = new ElectronStore();
         |               ^

THANKS A LOT IN ADVANCE!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants