cenfun / monocart-coverage-reports

A code coverage tool to generate native V8 reports or Istanbul reports.
MIT License
69 stars 6 forks source link

Error occurred while using in electron #27

Closed fanksy closed 5 months ago

fanksy commented 5 months ago

main.ts

import path from 'path';
import { app, BrowserWindow, shell, ipcMain } from 'electron';
import { autoUpdater } from 'electron-updater';
import log from 'electron-log';
import MCR, { CoverageReportOptions } from 'monocart-coverage-reports';
import MenuBuilder from './menu';
import { resolveHtmlPath } from './util';

class AppUpdater {
  constructor() {
    log.transports.file.level = 'info';
    autoUpdater.logger = log;
    autoUpdater.checkForUpdatesAndNotify();
  }
}
const reportOptions: CoverageReportOptions = {
  logging: 'debug',
  reports: [],`
  // v8 sub dir
  outputFile: 'reports/index.html',
  assetsPath: '../assets',
  reportPath: 'lcov.info',
  entryFilter: {
    '**/**': true,
  },
  sourceFilter: {
    '**/node_modules/**': false,
    '**/webpack/**': false,
    '**/**': true,
  },
  v8Ignore: true,
  clean: false,
};

MCR(reportOptions);

After packaging, an error occurs when opening.

npm run build && electron-builder build --publish never 
Screenshot 2024-05-25 at 23 44 30
cenfun commented 5 months ago

I am not familiar with Electron. Could you provide a minimal repo to reproduce it locally? I'm not sure if Electron can provide v8 coverage data, what is your specific use case?

fanksy commented 5 months ago

I am not familiar with Electron. Could you provide a minimal repo to reproduce it locally? I'm not sure if Electron can provide v8 coverage data, what is your specific use case?

you can clone a repository from https://github.com/electron-react-boilerplate/electron-react-boilerplate, then adding code below in main.ts

import MCR, { CoverageReportOptions } from 'monocart-coverage-reports';
const reportOptions: CoverageReportOptions = {};
MCR(reportOptions);

run the command

npm run package

last, opening the app in release dir

fanksy commented 5 months ago

I am not familiar with Electron. Could you provide a minimal repo to reproduce it locally? I'm not sure if Electron can provide v8 coverage data, what is your specific use case?

This just initializes the reporting options, no data collection will be triggered

cenfun commented 5 months ago

@fanksy please try new version monocart-coverage-reports@2.8.3, it should be fixed. A CLI library can not be initialized in Electron, but I don't think it is necessary to support CLI in Electron, so I separated that library to let the program continue work.