Electron에서 실행중인 React (webpack 포함)로 빌드 된 프로젝트에 참여하고 있습니다. Jest을 사용하여 단위 테스트를 실행하면 오류 TypeError: Cannot read property 'on' of undefined
과 함께 실패합니다 (테스트하지 않을 때, 예를 들어 전자로 실행).Electron + Jest - 유닛 테스트에서 ipcRenderer가 정의되지 않았습니다.
코드 :
import React, { Component } from 'react';
import { ipcRenderer } from 'electron';
// some more imports
class Setup extends Component {
constructor(props) {
super(props);
this.state = {
// some state
};
ipcRenderer.on('open-file-reply', this.someMethod); // << fails on this line
}
// more class stuff
}
필자는 Webpack의 "target": "electron"또는 "target": "electron-renderer"를 추가하는 것을 포함하여 많은 다른 솔루션을 시도했지만 이러한 것들은 효과가 없습니다 – Technotronic