Skip to content

Karma Unit tests are failing to run on Angular 15 #24472

@mivanyna

Description

@mivanyna

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

I'm working on an old angular project and the folder structure is a bit different from what's in angular documentation.

After upgrading to Angular 15 karma/jasmine unit tests are failing to run.
Project structure:
image

Karma config:

module.exports = function (config) {
  config.set({
    basePath: '..',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-phantomjs-launcher'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('karma-spec-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/testapp'),
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true
    },
    reporters: ['spec'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['ChromeHeadless'],
    singleRun: true,
    restartOnFileChange: true
  });
};

When I run UTs I get an error:
image

When running it with debug logging found:
image

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Error: Specified patterns: "**/*.spec.ts" did not match any spec files.

Please provide the environment you discovered this bug in (run ng version)

Angular: 15.0.4
Works on angular 14.2.4

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions