Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error while running karma test in angular 17 #348

Open
abhinavek opened this issue Jan 20, 2025 · 0 comments
Open

Error while running karma test in angular 17 #348

abhinavek opened this issue Jan 20, 2025 · 0 comments

Comments

@abhinavek
Copy link

I am running karma test in angular 17 app and getting the below error from karma. Please help to resolve this. Thanks in advance.

20 01 2025 06:18:15.581:ERROR [karma-server]: TypeError: Cannot read properties of undefined (reading 'filter')
    at D:\Abhinav\projects\access_control_management_fe\node_modules\karma\lib\file-list.js:74:12
    at Array.map (<anonymous>)
    at FileList._refresh (D:\Abhinav\projects\access_control_management_fe\node_modules\karma\lib\file-list.js:65:22)
    at FileList.refresh (D:\Abhinav\projects\access_control_management_fe\node_modules\karma\lib\file-list.js:160:29)
    at Server.refreshFiles (D:\Abhinav\projects\access_control_management_fe\node_modules\karma\lib\server.js:167:44)
    at D:\Abhinav\projects\access_control_management_fe\node_modules\@angular-devkit\build-angular\src\tools\webpack\plugins\karma\karma.js:169:25
    at Hook.eval [as callAsync] (eval at create (D:\Abhinav\projects\access_control_management_fe\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:38:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\Abhinav\projects\access_control_management_fe\node_modules\tapable\lib\Hook.js:18:14)
    at Watching._done (D:\Abhinav\projects\access_control_management_fe\node_modules\webpack\lib\Watching.js:314:28)
    at D:\Abhinav\projects\access_control_management_fe\node_modules\webpack\lib\Watching.js:229:21

below is my karma.config.js

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

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    files: [
      'src/**/*.spec.js', // Include all test files in the src directory
    ],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    client: {
      jasmine: {
        // you can add configuration options for Jasmine here
        // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
        // for example, you can disable the random execution with `random: false`
        // or set a specific seed with `seed: 4321`
      },
    },
    jasmineHtmlReporter: {
      suppressAll: true // removes the duplicated traces
    },
    coverageReporter: {
      dir: require('path').join(__dirname, './coverage/access_control_management_fe'),
      subdir: '.',
      reporters: [
        { type: 'html' },
        { type: 'text-summary' }
      ]
    },
    reporters: ['progress', 'kjhtml'],
    browsers: ['Chrome'],
    restartOnFileChange: true
  });
};
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant