Is it possible to run karma units tests in this repository?

I tried to run npm test in this repository but if I have any electron import in my angular services I get the following error:

Uncaught TypeError: fs.existsSync is not a function
at http://127.0.0.1:9876/_karma_webpack_/vendor.bundle.js:94

Is it possible to run karma units tests in this repository?

1 possible answer(s) on “Is it possible to run karma units tests in this repository?

  1. I fixed it this way:

    First I moved all electron dependent code in the ElectronService, like showing dialogs or opening shell.

    Changed imports to
    import { ipcRenderer } from 'electron';

    all other electron related properties like “remote” and “shell” are accessed via “this.electron” which is set this way:

    @Injectable()
    export class ElectronService {
      ipcRenderer: typeof ipcRenderer;
      childProcess: typeof childProcess;
      electron: any;
    
      constructor(private translateService: TranslateService) {
        // Conditional imports
        if (this.isElectron()) {
          this.electron = window.require('electron');
          this.ipcRenderer = this.electron.ipcRenderer;
          this.childProcess = window.require('child_process');
        }