简体   繁体   English

错误:在电子编译应用程序中通过Mocha和Spectron测试时找不到模块电子

[英]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. 我按照说明进行安装,因此在我的devDependencies中没有电子封装。 Instead of this I have electron-prebuild-compile dependency. 取而代之的是,我具有电子预编译-编译依赖性。 I have a problem with my code during writing unit tests with mocha + spectron. 在使用Mocha + Spectron编写单元测试期间,我的代码有问题。 I have module with function: 我有功能模块:

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

and I make shell import in front of module: 我将shell导入到模块的前面:

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? 我应该怎么做才能避免这个问题?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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