我实际上正在使用电子构建一个应用程序,而且我遇到了处理电子内置包的麻烦。
我有一个测试,看起来像使用chai mocha an:
it('should call the remote#hideWindow method', () => {
/**
* Mock definition
*/
mock.expects('getCurrentWindow').returns({
hide: () => {
// Do some job
}
});
const spy = chai.spy(remote.getCurrentWindow().hide);
/**
* Real test case
*/
const googleSearchBar = new GoogleSearchBar(document.getElementById('search'));
googleSearchBar.hideWindow();
expect(spy).to.have.been.called();
});
我的问题是我无法使用遥控器'包使用:
const remote = require('remote');
事实上,我可以要求('远程')在我的应用内部,一个在浏览器上运行,但不在我的测试中。而且我不知道如何在我的测试文件中访问它。
你能帮助我吗?
编辑:当我尝试使用Web API(例如通知或webspeechrecognition)时,会发生同样的事情。有什么想法吗?