升级到电容器 3 现在我的测试坏了

我目前正在运行 Angular 12,电容器 2 运行良好。现在我升级到版本 3,我的测试被破坏了,抛出了 ChunkErrors。像 Error: Uncaught (in promise): ChunkLoadError: Loading chunk node_modules_capacitor_toast_dist_esm_web_js failed. 似乎我所有的问题都来自新的插件实现。我很欣赏你可能有的任何见解。谢谢!

有人遇到过这个问题吗?

这是我的 karma.config.js

// Karma configuration file,see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function (config) {
config.set({
 basePath: '',frameworks: ['jasmine','@angular-devkit/build-angular'],plugins: [
  require('karma-jasmine'),require('karma-chrome-launcher'),require('karma-jasmine-html-reporter'),require('@angular-devkit/build-angular/plugins/karma'),require('karma-junit-reporter'),require('karma-spec-reporter'),require('karma-coverage'),require('karma-sonarqube-reporter'),require('ts-loader')
],client: {
  // leave Jasmine Spec Runner output visible in browser
  clearContext: false,jasmine: {
    random: false
  }
},reporters: ['progress','coverage','junit','spec','sonarqube'],mime: { 'text/x-typescript': ['ts','tsx'] },junitReporter: {
  outputDir: './test-results',outputFile: 'junit-unit-test-results.xml',useBrowserName: false
},coverageReporter: {
  // specify a common output directory
  dir: require('path').join(__dirname,'./coverage'),reports: ['cobertura','html','lcov','text'],reporters: [
    // reporters not supporting the `file` property
    { type: 'html',subdir: 'report-html' },{ type: 'lcov',subdir: 'report-lcov' },// reporters supporting the `file` property,use `subdir` to directly
    // output them in the `dir` directory
    { type: 'cobertura',subdir: '.',file: 'cobertura.txt' }
  ],fixWebpackSourcePaths: true,combineBrowserReports: true,skipFilesWithNoCoverage: true,includeAllSources: true,thresholds: {
    // set to `true` to not fail the test command when thresholds are not met
    emitWarning: false,// thresholds for all files
    global: {
      statements: 0,lines: 45,branches: 0,functions: 0
    },// thresholds per file
    each: {
      statements: 0,lines: 0,functions: 0
    }
  }
},port: 9876,colors: true,logLevel: config.LOG_DEBUG,autoWatch: true,browsers: ['CustomChromeHeadless'],browserNoactivityTimeout: 60000,browserDisconnectTimeout: 60000,browserDisconnectTolerance: 2,browserSocketTimeout: 80000,captureTimeout: 180000,sonarqubereporter: {
  basePath: 'src/app',filePattern: '**/*spec.ts',encoding: 'utf-8',outputFolder: 'test-results',legacyMode: false,reportName: () => {
    const metadata_SonarUnit = ['sonar-unit-test-results'];
    return metadata_SonarUnit.concat('xml').join('.');
  }
},singleRun: true,restartOnFileChange: false,customLaunchers: {
  CustomChromeHeadless: {
    base: 'ChromeHeadless',flags: [
      '--headless','--no-sandbox','--disable-gpu','--disable-translate','--disable-extensions','--disable-web-security','--remote-debugging-address=0.0.0.0','--remote-debugging-port=9222','--disable-dev-shm-usage'
    ],debug: true
    }
   }
 });
};
hhhh789512 回答:升级到电容器 3 现在我的测试坏了

按照此处的说明进行操作:https://github.com/ionic-team/cap-plugin-mock-jasmine

本文链接:https://www.f2er.com/9537.html

大家都在问