Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Tests are often not rerunning when files change #221

Open
jdcai opened this issue Apr 23, 2020 · 1 comment
Open

Tests are often not rerunning when files change #221

jdcai opened this issue Apr 23, 2020 · 1 comment

Comments

@jdcai
Copy link

jdcai commented Apr 23, 2020

I'm using karma with an angular project. When I do ng test --browsers=Chrome it will run the test the first time.
If I make a change to a file it will compile and then the tests won't get rerun. If I keep on trying to change a file it will randomly rerun test sometimes but most of the time it won't run them.
When it doesn't rerun tests it shows this in the debug messages and just stays there.

23 04 2020 14:46:30.985:DEBUG [karma-server]: List of files has changed, trying to execute
23 04 2020 14:46:30.986:DEBUG [karma]: All browsers are ready, executing
23 04 2020 14:46:30.986:DEBUG [karma]: Captured 1 browsers

It also happens with ChromeHeadless. It doesn't seem to happen with Firefox though.

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-firefox-launcher'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    client: {
      clearContext: true, 
      jasmine: {
        failSpecWithNoExpectations: true
      }
    },
    mime: {
      'text/x-typescript': ['ts', 'tsx']
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, './coverage'),
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true,
      thresholds: {
        emitWarning: false, 
        // thresholds for all files
        global: {
          statements: 80, 
          branches: 60, 
          functions: 75, 
          lines: 80, 
        },
        // thresholds per file
        each: {
          statements: 60, 
          lines: 60, 
          branches: 25, 
          functions: 35, 
        }
      },
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    browsers: ['ChromeHeadless', 'FirefoxHeadless'],
    captureTimeout: 120000,
    customLaunchers: {
      HeadlessChrome: {
        base: 'ChromeHeadless',
        flags: [
          '--headless',
          '--no-sandbox'
        ]
      },
      HeadlessFirefox: {
        base: 'FirefoxHeadless',
        flags: [
          '-headless',
        ],
      }
    },
    singleRun: false,
    restartOnFileChange: true
  });
};

Version
karma-chrome-launcher: 3.1.0
karma: 5.0.2

@tr1stan
Copy link

tr1stan commented Sep 26, 2023

I noticed this problem after upgrading an Angular app from 12 -> 14. it looks like updating to the latest version [email protected] has fixed the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants