简体   繁体   中英

Error: cannot find module electron while testing by mocha and spectron in electron-compile app

I try to write electron app with electron-prebuilt-compile package. I installed it follow the instructions, so in my devDependencies there is not electron package. Instead of this I have electron-prebuild-compile dependency. I have a problem with my code during writing unit tests with mocha + spectron. I have module with function:

openLinkinExternalWindow( e ) {                                                                                                                                                                                                       
  shell.openExternal(this.link);
}

and I make shell import in front of module:

import { shell } from 'electron';

It works during application runtime, but if I want to test this module, there is an error:

Cannot find module 'electron'

What should I do to avoid this problem?

我已经使用了电子摩卡包而不是摩卡包,它的工作原理

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM