1

Recently, I upgraded my angular project from v14 to v15. But after the upgrade, on running the test suite using the command ng test, I'm getting the following error:

I addressed the warning shown in the above screenshot but unfortunately, the issue didn't get resolved. Please help me in any way possible and let me know in case more details are needed.

For reference,

package.json

"dependencies": {
    "@angular/animations": "^15.2.10",
    "@angular/cdk": "^15.2.9",
    "@angular/common": "^15.2.10",
    "@angular/compiler": "^15.2.10",
    "@angular/core": "^15.2.10",
    "@angular/forms": "^15.2.10",
    "@angular/material": "^15.2.9",
    "@angular/platform-browser": "^15.2.10",
    "@angular/platform-browser-dynamic": "^15.2.10",
    "@angular/router": "^15.2.10",
    "@fortawesome/angular-fontawesome": "^0.5.0",
    "@fortawesome/fontawesome-free": "^5.15.4",
    "@fortawesome/fontawesome-svg-core": "^1.2.36",
    "@fortawesome/free-solid-svg-icons": "^5.15.4",
    "auth0-js": "^9.24.1",
    "bootstrap": "^5.3.3",
    "font-awesome": "^4.7.0",
    "jquery": "^3.7.1",
    "jwt-decode": "^2.2.0",
    "lodash": "^4.17.21",
    "material-icons": "^1.13.12",
    "ngx-mat-multi-sort": "^0.7.4",
    "ngx-mat-select-search": "^3.3.3",
    "ngx-toastr": "^16.2.0",
    "rxjs": "~6.6.0",
    "tslib": "^2.6.2",
    "uuid": "^9.0.1",
    "zone.js": "^0.11.8"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.2.11",
    "@angular-eslint/builder": "13.5.0",
    "@angular-eslint/eslint-plugin": "13.5.0",
    "@angular-eslint/eslint-plugin-template": "13.5.0",
    "@angular-eslint/schematics": "13.5.0",
    "@angular-eslint/template-parser": "13.5.0",
    "@angular/cli": "^15.2.11",
    "@angular/compiler-cli": "^15.2.10",
    "@angular/language-service": "^15.2.10",
    "@types/auth0-js": "^9.21.5",
    "@types/jasmine": "~3.8.0",
    "@types/lodash": "^4.17.0",
    "@types/node": "^12.20.55",
    "@typescript-eslint/eslint-plugin": "4.28.2",
    "@typescript-eslint/parser": "4.28.2",
    "eslint": "^7.26.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "^6.4.3",
    "karma-chrome-launcher": "^3.2.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "^4.0.2",
    "karma-jasmine-html-reporter": "^1.5.0",
    "karma-junit-reporter": "^1.2.0",
    "karma-spec-reporter": "0.0.32",
    "ng-packagr": "^15.2.2",
    "protractor": "~7.0.0",
    "puppeteer": "^1.20.0",
    "ts-node": "~7.0.0",
    "typescript": "^4.8.4"
  },
  "resolutions": {
    "glob-parent": "^5.1.2",
    "set-value": "^4.0.1",
    "ansi-regex": "^5.0.1"
  }

karma.conf.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('karma-coverage-istanbul-reporter'),
            require('karma-spec-reporter'),
            require('karma-junit-reporter'),
            require('@angular-devkit/build-angular/plugins/karma')
        ],
        client: {
            clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
        coverageIstanbulReporter: {
            dir: require('path').join(__dirname, './coverage'),
            reports: ['text-summary', 'cobertura'],
            fixWebpackSourcePaths: true,
            combineBrowserReports: true,
            'report-config': {
                cobertura: {
                    // the default, but better to be explicit
                    file: 'cobertura-coverage.xml'
                }
            },
        },
        files: [
            'node_modules/jquery/dist/jquery.min.js'
        ],
        junitReporter: {
            outputDir: './reports',
            outputFile: 'junit.xml',
            useBrowserName: false
            // nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
            // classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
            // properties: {}, // key value pair of properties to add to the <properties> section of the report
            /// xmlVersion: null // use '1' if reporting to be per SonarQube 6.2 XML format
        },
        reporters: ['progress', 'kjhtml', 'spec', 'coverage-istanbul', 'junit'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['ChromeHeadlessNoSandbox'],
        customLaunchers: {
            ChromeHeadlessNoSandbox: {
                base: 'ChromeHeadless',
                flags: ['--no-sandbox']
            }
        },
        singleRun: false,
        restartOnFileChange: true
    });
};
8
  • Does this help : github.com/karma-runner/karma/issues/3417 ? Commented May 13, 2024 at 11:47
  • Already looked at that, I don't have the .babelrc file, so don't know where to add the plugin mentioned in that solution. Commented May 13, 2024 at 11:52
  • Can you provide the package.json , the karma conf and the test that you're trying to run ? Commented May 13, 2024 at 11:54
  • @ArnaudFlaesch, I've added them now above, please check. Commented May 13, 2024 at 12:07
  • Thanks, please also add one of the spec files you try to run Commented May 13, 2024 at 12:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.