Karma Load Error in Angular Tests with --code-coverage: "Error: Found 1 load error"

Discussão em 'Angular' iniciado por Abdullah Khalid, Outubro 30, 2024.

  1. I'm encountering a persistent "load error" when running Angular tests with --code-coverage. This error only occurs with the command ng test --no-watch --code-coverage; otherwise, running ng test without --code-coverage works perfectly.

    Karma Configuration (karma.conf.js):

    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('karma-coverage'),
    require('@angular-devkit/build-angular/plugins/karma')
    ],
    client: { clearContext: false },
    coverageReporter: {
    dir: require('path').join(__dirname, '../coverage/DATAGERRYApp'),
    reporters: [{ type: 'html' }, { type: 'lcovonly' }, { type: 'text-summary' }],
    fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG, // Enabled for detailed logging
    autoWatch: true,
    browsers: ['ChromeHeadless'],
    singleRun: true,
    restartOnFileChange: true
    });
    };


    **Command Used: ** ng test --no-watch --code-coverage

    **Error Output: **

    Error: Found 1 load error at Server.<anonymous> (/path/to/project/node_modules/karma/lib/server.js:243:26)

    Steps I've Tried:

    • Cleared node_modules and reinstalled dependencies.
    • Updated karma.conf.js to use karma-coverage instead of karma-coverage-istanbul-reporter.
    • Ran ng build --configuration test to check for circular dependencies.
    • Cleared Angular cache with ng cache clean.

    Continue reading...

Compartilhe esta Página