"ReferenceError: require is not defined at Object.child_process" for Electron app while running karma test cases

We have a Electron App build using Angular 4, NodeJS & Electron, Webpack.

We have few of the UI components calling child_process & fs modules, because of which we are getting below error while running test cases using karma:

“HeadlessChrome 0.0.0 (Windows 10 0.0.0) ERROR: ‘ReferenceError:
require is not defined
at Object.child_process”

Please suggest ways to work around this issue.

Source: AngularJS