Spectacular Test Runner for JavaScript

Overview

Karma

js-standard-style npm version npm downloads

Build Status Build Status Code Climate PRs Welcome Dependency Status devDependency Status semantic-release

A simple tool that allows you to execute JavaScript code in multiple real browsers.

The main purpose of Karma is to make your test-driven development easy, fast, and fun.

Help and Support

For questions and support please use the mailing list or Gitter. The issue tracker is for bug reports and feature discussions only.

When should I use Karma?

  • You want to test code in real browsers.
  • You want to test code in multiple browsers (desktop, mobile, tablets, etc.).
  • You want to execute your tests locally during development.
  • You want to execute your tests on a continuous integration server.
  • You want to execute your tests on every save.
  • You love your terminal.
  • You don't want your (testing) life to suck.
  • You want to use Istanbul to automagically generate coverage reports.
  • You want to use RequireJS for your source files.

But I still want to use _insert testing library_

Karma is not a testing framework, nor an assertion library. Karma just launches an HTTP server, and generates the test runner HTML file you probably already know from your favourite testing framework. So for testing purposes you can use pretty much anything you like. There are already plugins for most of the common testing frameworks:

If you can't find an adapter for your favourite framework, don't worry and write your own. It's not that hard and we are here to help.

Which Browsers can I use?

All the major browsers are supported, if you want to know more see the browsers page.

Troubleshooting

See FAQ.

I want to use it. Where do I sign?

You don't need to sign anything but here are some resources to help you to get started...

Obligatory Screencast.

Every serious project has a screencast, so here is ours. Just click here and let the show begin.

Installation.

See installation.

Using it.

See configuration.

This is so great. I want to help.

Please, see contributing.

Why did you create this?

Throughout the development of AngularJS, we've been using JSTD for testing. I really think that JSTD is a great idea. Unfortunately, we had many problems with JSTD, so we decided to write our own test runner based on the same idea. We wanted a simple tool just for executing JavaScript tests that is both stable and fast. That's why we use the awesome Socket.io library and Node.js.

My boss wants a license. So where is it?

MIT License

Comments
  • Suggestion to rename the project

    Suggestion to rename the project

    I'm okay with a solid pun in conversation but its really hard to suggest using testacular in many, many settings.

    Or at least stick to the (spec|test)acular combined word in marketing and quit talking about "balls".

    opened by ryanflorence 138
  • Karma is not able to run test cases on phantomJS

    Karma is not able to run test cases on phantomJS

    I have been trying to get Karma to run tests on PhantomJS for the last couple of hours and seem to be stuck at it. I had my entire suit run tests in Chrome and it ran without a quirk. on trying to run it with Karma, it would just not run.

    I was running phantomjs 1.9 and then i reverted to 1.8. i tried installing it from the distributed binary from the phantomjs site and i also tried to install it through npm. But i had no avail in any of the combinations. I am on a 64bit Ubuntu machine.

    I am pretty sure my configurations are correct and i checked phantomjs which again seems to be working.

    Am i missing something here. or is this some bizarre bug.

    I am attaching my debug logs below.

    DEBUG [reporter]: Using reporter "dots".
    DEBUG [reporter]: Using reporter "junit".
    INFO [karma]: Karma server started at http://localhost:9876/
    INFO [launcher]: Starting browser PhantomJS
    DEBUG [launcher]: Creating temp dir at /tmp/testacular-86450027
    DEBUG [launcher]: phantomjs /tmp/testacular-86450027/capture.js
    DEBUG [watcher]: Resolved files:
        /home/kausikram/lib/node_modules/karma/adapter/lib/jasmine.js
        /home/kausikram/lib/node_modules/karma/adapter/jasmine.js
        /home/kausikram/Projects/scloud/src/main/webapp/resources/jquery/jquery.js
        /home/kausikram/Projects/scloud/src/main/webapp/resources/jquery/jquery.dynoform.js
    [...]
    
    DEBUG [web server]: serving: /home/kausikram/lib/node_modules/karma/static/client.html
    DEBUG [web server]: serving: /home/kausikram/lib/node_modules/karma/static/testacular.js
    DEBUG [karma]: New browser has connected on socket s2jUXmnylvNYdQux4Wc2
    WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
    DEBUG [launcher]: Process PhantomJS exitted with code 1
    ERROR [launcher]: Cannot start PhantomJS
    
    DEBUG [launcher]: Cleaning temp dir /tmp/testacular-86450027
    INFO [launcher]: Trying to start PhantomJS again.
    DEBUG [launcher]: Creating temp dir at /tmp/testacular-86450027
    DEBUG [launcher]: phantomjs /tmp/testacular-86450027/capture.js
    DEBUG [web server]: serving: /home/kausikram/lib/node_modules/karma/static/client.html
    DEBUG [web server]: serving: /home/kausikram/lib/node_modules/karma/static/testacular.js
    DEBUG [karma]: New browser has connected on socket 3qsGGwLPK5ogNJs_4Wc3
    WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
    DEBUG [launcher]: Process PhantomJS exitted with code 1
    ERROR [launcher]: Cannot start PhantomJS
    
    needs: investigation 
    opened by kausikram 105
  • Karma 1.6 breaks Headless support for Chrome

    Karma 1.6 breaks Headless support for Chrome

    Expected behaviour

    When using Karma 1.6, you should be able to use chrome headless support

    Actual behaviour

    Chrome won't start with headless mode

    > karma start --single-run --browsers=Chrome_Beta_Headless
    07 04 2017 15:21:17.494:WARN [watcher]: All files matched by "/opt/atlassian/pipelines/agent/build/packages/sams-client/dist/_test/_setup/main.js" were excluded or matched by prior matchers.
    07 04 2017 15:21:18.853:INFO [karma]: Karma v1.6.0 server started at http://0.0.0.0:9876/
    07 04 2017 15:21:18.854:INFO [launcher]: Launching browser Chrome_Beta_Headless with unlimited concurrency
    07 04 2017 15:21:18.863:INFO [launcher]: Starting browser Chrome
    07 04 2017 15:21:19.403:INFO [HeadlessChrome 0.0.0 (Linux 0.0.0)]: Connected on socket NKuNZ76kZe8lL7FnAAAA with id 75816684
    07 04 2017 15:21:29.405:WARN [HeadlessChrome 0.0.0 (Linux 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
    HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR
      Disconnected, because no message in 10000 ms.
    

    Environment Details

    • Karma version (output of karma --version): 1.6
    • Relevant part of your karma.config.js file
        browsers: ["Chrome", "Chrome_Beta_Headless"],
    
        customLaunchers: {
          Chrome_Beta_Headless: {
            base: 'Chrome',
            flags: ['--headless', '--disable-gpu', '--remote-debugging-port=9222']
          }
        },
    

    Steps to reproduce the behaviour

    1. Setup a custom launcher as above
    2. karma start --single-run --browsers=Chrome_Beta_Headless
    3. Get the error above.
    4. Rollback to Karma 1.5, everything works.
    needs: investigation needs: feedback-from-author 
    opened by omniscient 97
  • feat: support asynchronous `config.set()` call in karma.conf.js

    feat: support asynchronous `config.set()` call in karma.conf.js

    With this change, Karma allows to return a Promise from a configuration function directly or make such function async and thus allows to perform some asynchronous initialization/fetch configuration from somewhere. When the configuration function returns a Promise, Karma will wait until the promise is resolved before it proceeds with the next steps.

    Example usage:

    module.exports = async (config) => {
      const karmaConfig = await getKarmaConfig("dev");
      
      config.set({
        ...karmaConfig
      });
    };
    

    For Karma's end-users the change is fully backward compatible. For Karma's programmatic users the change is backward compatible, but the current behavior of parseConfig(), Server, runner, and stopper is deprecated and will change in the next major release. New behavior (which supports asynchronous configuration function) can be enabled with a flag. Please refer to the public API documentation for more details.

    Fixes #1259

    released 
    opened by npetruzzelli 55
  • [object ErrorEvent] thrown in angular app, Debug window.

    [object ErrorEvent] thrown in angular app, Debug window.

    Expected behaviour

    Passing tests in the command line should match passing tests in the karma debugger.

    Actual behaviour

    In debug browser, a test that passes according to the command line fails in the debug browser with error message: [object ErrorEvent] thrown.

    Environment Details

    • Karma version (output of karma --version):
    • Relevant part of your karma.config.js file

    There error itself is being thrown in zone.js/dist/zone.js: 195 , with zone.js version = 0.8.12.

    From package.json

    "devDependencies": {
            "@ionic/app-scripts": "2.1.4",
            "@types/jasmine": "^2.6.0",
            "@types/node": "^8.0.19",
            "angular2-template-loader": "^0.6.2",
            "html-loader": "^0.5.1",
            "istanbul-instrumenter-loader": "^3.0.0",
            "jasmine": "^2.8.0",
            "jasmine-spec-reporter": "^4.2.1",
            "karma": "^1.7.1",
            "karma-chrome-launcher": "^2.2.0",
            "karma-coverage-istanbul-reporter": "^1.3.0",
            "karma-jasmine": "^1.1.0",
            "karma-jasmine-html-reporter": "^0.2.2",
            "karma-sourcemap-loader": "^0.3.7",
            "karma-webpack": "^2.0.5",
            "null-loader": "^0.1.1",
            "protractor": "^5.2.0",
            "ts-loader": "^3.0.3",
            "ts-node": "^3.3.0",
            "typescript": "~2.4.0"
        },
    

    karma.conf.js

    var webpackConfig = require('./webpack.test.js');
    
    module.exports = function(config) {
      var _config = {
        basePath: '../',
    
        frameworks: ['jasmine'],
    
        files: [
          {
            pattern: './test-config/karma-test-shim.js',
            watched: true
          },
          {
            pattern: './src/assets/**/*',
            watched: false,
            included: false,
            served: true,
            nocache: false
          }
        ],
    
        proxies: {
          '/assets/': '/base/src/assets/'
        },
    
        preprocessors: {
          './test-config/karma-test-shim.js': ['webpack', 'sourcemap']
        },
    
        webpack: webpackConfig,
    
        webpackMiddleware: {
          stats: 'errors-only'
        },
    
        webpackServer: {
          noInfo: true
        },
    
        browserConsoleLogOptions: {
          level: 'log',
          format: '%b %T: %m',
          terminal: true
        },
    
        coverageIstanbulReporter: {
          reports: [ 'html', 'lcovonly' ],
          fixWebpackSourcePaths: true
        },
    
        reporters: config.coverage ? ['kjhtml', 'dots', 'coverage-istanbul'] : ['kjhtml', 'dots'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Chrome'],
        singleRun: false
      };
    
      config.set(_config);
    };
    

    karma-test-shim.js

    
    require('core-js/es6');
    require('core-js/es7/reflect');
    
    require('zone.js/dist/zone');
    require('zone.js/dist/long-stack-trace-zone');
    require('zone.js/dist/proxy');
    require('zone.js/dist/sync-test');
    require('zone.js/dist/jasmine-patch');
    require('zone.js/dist/async-test');
    require('zone.js/dist/fake-async-test');
    
    var appContext = require.context('../src', true, /\.spec\.ts/);
    
    appContext.keys().forEach(appContext);
    
    var testing = require('@angular/core/testing');
    var browser = require('@angular/platform-browser-dynamic/testing');
    
    testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting());
    

    The test itself:

    I removed the @Injectable tag in the hopes that it would isolate angular from the issue. The test "LocationService Lat/Lon to tile conversion should match for the two lat2TileY functions" (the last test) is the one that passes in the command line but fails in the debugger.

    Also, I can get the test to pass if I comment out the two tests preceding the last test, but not if I comment out the second-to-last test or the third-to-last test only. Kind of puzzled as to how that's happening.

    import { Coordinates, Geolocation } from '@ionic-native/geolocation';
    import { LocationNoAngular } from './location-no-angular';
    import { LocationService } from './location.service';
    import * as LocationTestData from './location-spec-data';
    
    describe('LocationService', () => {
      let locationService: LocationNoAngular;
      const epsilon = .004;
      beforeAll(() => {
        locationService = new LocationNoAngular(new Geolocation());
      });
    
      describe('getDistanceFunction', () => {
        it('should return zero for identical locations', () => {
          const distance: number = locationService.getDistance(
            LocationTestData.zeroDistanceTestPoint,
            LocationTestData.zeroDistanceTestPoint
          );
    
          expect(Math.abs(distance)).toBeLessThan(epsilon);
        });
    
        it('should return 179.9 for distance between known coordinates', () => {
          const distance: number = locationService.getDistance(
            LocationTestData.knownDistanceTestPoint1,
            LocationTestData.knownDistanceTestPoint2
          );
    
          expect(Math.abs(distance - LocationTestData.knownDistance)).toBeLessThan(epsilon);
        });
      });
    
      describe('Lat/Lon to tile conversion', () => {
        it('should map longitude to x tiles 0, 1, 2, 3 on lower bound', () => {
          expect(locationService.lon2TileX(-180, 2)).toEqual(0);
          expect(locationService.lon2TileX(-90, 2)).toEqual(1);
          expect(locationService.lon2TileX(0, 2)).toEqual(2);
          expect(locationService.lon2TileX(90, 2)).toEqual(3);
        });
    
        it('should map longitude to x tiles 0, 1, 2, 3 on upper boundbound', () => {
          expect(locationService.lon2TileX(-91, 2)).toEqual(0);
          expect(locationService.lon2TileX(-1, 2)).toEqual(1);
          expect(locationService.lon2TileX(89, 2)).toEqual(2);
          expect(locationService.lon2TileX(179, 2)).toEqual(3);
        });
    
        it('should match the alternative lat/lon to tile function', () => {
          expect(locationService.lon2TileX(-91, 2)).toEqual(locationService.lon2TileXVerify(-91, 2));
          expect(locationService.lon2TileX(-1, 2)).toEqual(locationService.lon2TileXVerify(-1, 2));
          expect(locationService.lon2TileX(89, 2)).toEqual(locationService.lon2TileXVerify(89, 2));
          expect(locationService.lon2TileX(179, 2)).toEqual(locationService.lon2TileXVerify(179, 2));
        });
    
        it('should map lat2TileY between 0, 1, 2, 3', () => {
          expect(locationService.lat2TileY(-85, 2)).toEqual(3);
          expect(locationService.lat2TileY(-66, 2)).toEqual(2);
          expect(locationService.lat2TileY(1, 2)).toEqual(1);
          expect(locationService.lat2TileY(67, 2)).toEqual(0);
          expect(true).toBe(true);
        });
    
        it('should map lat2TileY between 0, 1, 2, 3', () => {
          expect(locationService.lat2TileY(-85, 2)).toEqual(3);
          expect(locationService.lat2TileY(-66, 2)).toEqual(2);
          expect(locationService.lat2TileY(1, 2)).toEqual(1);
          expect(locationService.lat2TileY(67, 2)).toEqual(0);
        });
    
        it('should match for the two lat2TileY functions', function() {
          expect(locationService.lat2TileY(-85, 2)).toEqual(locationService.lat2TileYVerify(-85, 2));
          expect(locationService.lat2TileY(-60, 2)).toEqual(locationService.lat2TileYVerify(-60, 2));
          expect(locationService.lat2TileY(1, 2)).toEqual(locationService.lat2TileYVerify(1, 2));
          expect(locationService.lat2TileY(67, 2)).toEqual(locationService.lat2TileYVerify(67, 2));
        });
    
    
      });
    
    })
    
    

    The LocationNoAngular class (abbreviated)

    export class LocationNoAngular {
    
      private locationSubscription: Subscription;
      private currentLocation: Geoposition
      public locationData: Subject<Geoposition>;
      public readonly metersPerDegreeLat: number = 111111;
    
      constructor(private geolocation: Geolocation) {
        this.locationData = new Subject<any>();
    
      }
    
    ...skipping some methods...
    
      lon2TileXVerify(lon, zoom) {
        return (Math.floor((lon + 180) / 360 * Math.pow(2, zoom)));
      }
    
      lat2TileYVerify(lat, zoom) {
        return (Math.floor((1-Math.log(Math.tan(lat*Math.PI/180) + 1/Math.cos(lat*Math.PI/180))/Math.PI)/2 *Math.pow(2,zoom)));
      }
    
      // https://msdn.microsoft.com/en-us/library/bb259689.aspx
      lon2TileX(lon, zoom) {
        return Math.floor(((lon + 180) / 360) * Math.pow(2, zoom));
      }
    
      lat2TileY(lat, zoom) {
        const sinLatitude: number = Math.sin(this.degreesToRadians(lat));
        return Math.floor((.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI)) * Math.pow(2, zoom));
      }
    

    Steps to reproduce the behaviour

    Hopefully the above information is enough, but happy to setup more detail if necessary. It's an ionic3 project.

    opened by ZenPylon 49
  • Just updated to .13, Cannot read property 'mtime' of undefined

    Just updated to .13, Cannot read property 'mtime' of undefined

    5:38:03] TypeError: Cannot read property 'mtime' of undefined
        at c:\git\pos\node_modules\karma\lib\file-list.js:173:37
        at Array.map (native)
        at c:\git\pos\node_modules\karma\lib\file-list.js:167:30
        at Array.map (native)
        at List._refresh (c:\git\pos\node_modules\karma\lib\file-list.js:150:37)
        at List.refresh (c:\git\pos\node_modules\karma\lib\file-list.js:249:27)
        at Server._start (c:\git\pos\node_modules\karma\lib\server.js:149:12)
        at invoke (c:\git\pos\node_modules\karma\node_modules\di\lib\injector.js:75:15)
        at Server.start (c:\git\pos\node_modules\karma\lib\server.js:91:18)
        at runTests (c:\git\pos\gulpfile.js:684:11)
        at c:\git\pos\gulpfile.js:714:6
        at bound (domain.js:254:14)
        at runBound (domain.js:267:12)
        at asyncRunner (c:\git\pos\node_modules\gulp\node_modules\undertaker\node_modules\bach\node_modules\async-done\index.js:38:18)
        at process._tickCallback (node.js:355:11)
        at Function.Module.runMain (module.js:503:11)
    
    type: bug windows priority: high 
    opened by ghost 48
  • feat: pass command line opts through to browser

    feat: pass command line opts through to browser

    For large test suites, always running all the tests is slow. This change allows command-line arguments to be passed through to the runner as the single option to __karma__.run. This allows you to target specific tests per-run (when combined with a browser-side runner function that uses this feature).

    BREAKING CHANGE:

    The config file is no longer assumed to be the first argument, it must be specified with either -c or --config-file. I had to do this in order for unknown arguments to be pass through unmolested.

    opened by timbertson 48
  • Reorganize Testacular

    Reorganize Testacular

    As more and more preprocessors, adapters and browsers are getting added to testacular I think it would be a good idea to split them into sperate repos and create a modular system to require them. I would suggest the following:

    • Move Testacular to its own Github organization TestacularJS
    • Create a main repo testacular
    • Create the following repos
      • testacular-browsers
      • testacular-reporters
      • testacular-adapters
      • testacular-preprocessors
    • Remove all branches except for stable and master from the main repo.

    Only the most basic stuff would remain in the main repo and all the other modules would be loaded if needed. For loading I would suggest something like Grunt uses, in your config file do

    loadPreprocesor('awesome-preprocessor-on-npm');
    // or
    loadPreprocesor('./relative/preprocessor/that/is/local');
    

    What do you guys think about that?

    needs: investigation type: refactor discuss 
    opened by dignifiedquire 48
  • random DISCONNECTED messages from PhantomJS

    random DISCONNECTED messages from PhantomJS

    Hi, Karma: 0.8.6 PhantomJS: 1.9 Node: v0.10.2, v0.10.7

    I'm seeing random disconnect messages in single run mode. Is this a known problem? I tried monkey patching the socket.io transports to only do xhr and jsonp but it still happens. Any ideas?

    opened by ibawt 47
  • "Delaying execution, these browsers are not ready" Error

    Hi, I've been having this issue for a couple of weeks now, and its driving me nuts.

    I have my setup configured to retest on every save, but now after a couple of changes in the code and saving, after 3 or 4 saves the tests don't run anymore and I get this message:

    INFO [testacular]: Delaying execution, these browsers are not ready: PhantomJS 1.8 (Linux)
    

    changing browser

    INFO [testacular]: Delaying execution, these browsers are not ready: Chrome 25.0 (Linux)
    

    As you can see, it happens when using Chrome as well as PhantomJS

    Restarting Karma fixes the problem, but after a couple of saves I'm in the same situation.

    Additional info: I'm on linux and using coffeescript.

    support 
    opened by mpaulucci 43
  • Installing failed karma@0.10.9

    Installing failed [email protected]

    Installing failed [email protected]

    $ npm install [email protected]
    npm ERR! peerinvalid The package karma does not satisfy its siblings' peerDependencies requirements!
    npm ERR! peerinvalid Peer [email protected] wants karma@~0.10.0
    npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9.3
    npm ERR! peerinvalid Peer [email protected] wants karma@>=0.11.14
    npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
    npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
    npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
    npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
    npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
    npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
    
    npm ERR! System Darwin 13.1.0
    npm ERR! command "/Users/vvakame/.nodebrew/current/bin/node" "/Users/vvakame/.nodebrew/current/bin/npm" "install" "[email protected]"
    npm ERR! cwd /Users/vvakame/Downloads/karma
    npm ERR! node -v v0.10.26
    npm ERR! npm -v 1.4.3
    npm ERR! code EPEERINVALID
    npm ERR! 
    npm ERR! Additional logging details can be found in:
    npm ERR!     /Users/vvakame/Downloads/karma/npm-debug.log
    npm ERR! not ok code 0
    

    [email protected] wants karma@>=0.11.14 and karma's package.json"karma-coffee-preprocessor": "*"

    opened by vvakame 42
  • Karma cannot start Chrome version 108.0.5359.125

    Karma cannot start Chrome version 108.0.5359.125

    After Chrome auto updated to version 108.0.5359.125, karma can no longer start chrome. It gives the below output and then tries to open chrome 2 more times. Each time it will open karma in a new chrome tab (not a window) but will never connect to it and won't actually run the tests. Both ChromeHeadless and Firefox seem to run fine which makes me think it has something to do with the latest Chrome version.

    19 12 2022 11:20:58.275:INFO [karma-server]: Karma v6.3.20 server started at http://localhost:9876/
    19 12 2022 11:20:58.275:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
    19 12 2022 11:20:58.285:INFO [launcher]: Starting browser Chrome
    19 12 2022 11:20:58.287:DEBUG [launcher]: null -> BEING_CAPTURED
    19 12 2022 11:20:58.289:DEBUG [temp-dir]: Creating temp dir at C:\Users\chrism4\AppData\Local\Temp\karma-77373876
    19 12 2022 11:20:58.291:DEBUG [launcher]: C:\Program Files\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\chrism4\AppData\Local\Temp\karma-77373876 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications http://localhost:9876/?id=77373876
    - Generating browser application bundles (phase: building)...19 12 2022 11:21:00.449:DEBUG [launcher]: Process Chrome exited with code 0 and signal null
    19 12 2022 11:21:00.451:ERROR [launcher]: Cannot start Chrome
    
    19 12 2022 11:21:00.455:ERROR [launcher]: Chrome stdout: Opening in existing browser session.
    
    19 12 2022 11:21:00.456:ERROR [launcher]: Chrome stderr:
    19 12 2022 11:21:00.456:DEBUG [temp-dir]: Cleaning temp dir C:\Users\chrism4\AppData\Local\Temp\karma-77373876
    | Generating browser application bundles (phase: building)...19 12 2022 11:21:00.916:INFO [launcher]: Trying to start Chrome again (1/2).
    19 12 2022 11:21:00.918:DEBUG [launcher]: BEING_CAPTURED -> RESTARTING
    19 12 2022 11:21:00.921:DEBUG [launcher]: RESTARTING -> FINISHED
    19 12 2022 11:21:00.922:DEBUG [launcher]: Restarting Chrome
    19 12 2022 11:21:00.923:DEBUG [launcher]: FINISHED -> BEING_CAPTURED
    19 12 2022 11:21:00.923:DEBUG [temp-dir]: Creating temp dir at C:\Users\chrism4\AppData\Local\Temp\karma-77373876
    19 12 2022 11:21:00.925:DEBUG [launcher]: C:\Program Files\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\chrism4\AppData\Local\Temp\karma-77373876 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications http://localhost:9876/?id=77373876
    | Generating browser application bundles (phase: building)...19 12 2022 11:21:02.515:DEBUG [launcher]: Process Chrome exited with code 0 and signal null
    19 12 2022 11:21:02.523:ERROR [launcher]: Cannot start Chrome
    
    19 12 2022 11:21:02.530:ERROR [launcher]: Chrome stdout: Opening in existing browser session.
    
    19 12 2022 11:21:02.531:ERROR [launcher]: Chrome stderr:
    19 12 2022 11:21:02.534:DEBUG [temp-dir]: Cleaning temp dir C:\Users\chrism4\AppData\Local\Temp\karma-77373876
    - Generating browser application bundles (phase: building)...19 12 2022 11:21:03.422:INFO [launcher]: Trying to start Chrome again (2/2).
    19 12 2022 11:21:03.422:DEBUG [launcher]: BEING_CAPTURED -> RESTARTING
    19 12 2022 11:21:03.423:DEBUG [launcher]: RESTARTING -> FINISHED
    19 12 2022 11:21:03.423:DEBUG [launcher]: Restarting Chrome
    19 12 2022 11:21:03.423:DEBUG [launcher]: FINISHED -> BEING_CAPTURED
    19 12 2022 11:21:03.424:DEBUG [temp-dir]: Creating temp dir at C:\Users\chrism4\AppData\Local\Temp\karma-77373876
    19 12 2022 11:21:03.425:DEBUG [launcher]: C:\Program Files\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\chrism4\AppData\Local\Temp\karma-77373876 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications http://localhost:9876/?id=77373876
    / Generating browser application bundles (phase: building)...19 12 2022 11:21:05.869:DEBUG [launcher]: Process Chrome exited with code 0 and signal null
    19 12 2022 11:21:05.874:ERROR [launcher]: Cannot start Chrome
    
    19 12 2022 11:21:05.877:ERROR [launcher]: Chrome stdout: Opening in existing browser session.
    
    19 12 2022 11:21:05.878:ERROR [launcher]: Chrome stderr:
    19 12 2022 11:21:05.879:DEBUG [temp-dir]: Cleaning temp dir C:\Users\chrism4\AppData\Local\Temp\karma-77373876
    - Generating browser application bundles (phase: building)...19 12 2022 11:21:08.628:ERROR [launcher]: Chrome failed 2 times (cannot start). Giving up.
    19 12 2022 11:21:08.628:DEBUG [launcher]: BEING_CAPTURED -> FINISHED
    

    Environment Details

    • karma versions: "karma": "~6.3.12", "karma-chrome-launcher": "~3.1.1", "karma-coverage": "~2.2.0", "karma-firefox-launcher": "^2.1.2", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "karma-parallel": "^0.3.1", "karma-sabarivka-reporter": "^3.2.0", "karma-teamcity-reporter": "^1.1.0", "karma-verbose-reporter": "0.0.6"

    • karma.conf.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'],
        plugins: [
          require('karma-jasmine'),
          require('karma-chrome-launcher'),
          require('karma-firefox-launcher'),
          require('karma-jasmine-html-reporter'),
          require('karma-coverage'),
          require('karma-teamcity-reporter'),
          require('@angular-devkit/build-angular/plugins/karma')
        ],
        client: {
          clearContext: false, // leave Jasmine Spec Runner output visible in browser
          args: {
            random: false
          }
        },
        customLaunchers: {
          ChromeHeadlessNoSandbox: {
            base: 'ChromeHeadless',
            flags: [
              '--no-sandbox',
              '--disable-gpu',
              '--disable-web-security'
            ]
          }
        },
        jasmineHtmlReporter: {
          suppressAll: true // removes the duplicated traces
        },
        coverageReporter: {
          dir: require('path').join(__dirname, './coverage/ngfnex-ui'),
          subdir: '.',
          fixWebpackSourcePaths: true,
          reporters: [
            { type: 'html' },
            { type: 'text-summary' }
          ],
          check: {
            emitWarning: true,
            global: {
              statements: 80,
              branches: 80,
              functions: 80,
              lines: 80
            }
          }
        },
        reporters: ['progress', 'kjhtml', 'teamcity'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_DEBUG,
        autoWatch: true,
        browsers: ['Chrome'],
        singleRun: false,
        restartOnFileChange: true
      });
    };
    

    Steps to reproduce the behaviour

    1. Update to chrome to latest version (108.0.5359.125)
    2. Run ng test in angular project using karma
    opened by thecheeto 0
  • docs: Fix a few typos

    docs: Fix a few typos

    There are small typos in:

    • context/main.js
    • docs/dev/04-public-api.md
    • static/context.js

    Fixes:

    • Should read permission rather than permisison.
    • Should read asynchronous rather than aynchronous.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • Critical vulnerability: Insufficient validation when decoding a Socket.IO packet

    Critical vulnerability: Insufficient validation when decoding a Socket.IO packet

    Hello,

    We are currently facing a critical vulnerability in our project that depends on karma. https://github.com/advisories/GHSA-qm95-pgcg-qqfq

    Steps to reproduce: npm install npm audit

    Console message:

    ├─ socket.io-parser: 4.0.4                                                                                                                                 
    │  ├─ Issue: Insufficient validation when decoding a Socket.IO packet                                                                                      
    │  ├─ URL: https://github.com/advisories/GHSA-qm95-pgcg-qqfq                                                                                               
    │  ├─ Severity: critical                                                                                                                                   
    │  ├─ Vulnerable Versions:                                                                                                                           
    │  ├─ Patched Versions: >=4.0.5                                                                                                                            
    │  ├─ Via: karma, karma-htmlfile-reporter, karma-jasmine-html-reporter                                                                                     
    │  └─ Recommendation: Upgrade to version 4.0.5 or later   
    

    Thank you in advance.

    opened by salomedo 10
  • Unit Tests Sporadically Disconnect on our CI:CD builds

    Unit Tests Sporadically Disconnect on our CI:CD builds

    Hi Karma team,

    I'm part of an Angular project for my organization with a CI:CD build running approx. 1260 unit tests. We run these unit tests as part of a nightly build.

    Our builds run the following command to launch the unit tests: ng test [project_name] --browsers=ChromeHeadless --watch=false --source-map=false

    After 921 passing tests, the unit test portion of our build fails with the following error: Disconnected (0 times) reconnect failed before timeout of 2000ms (ping timeout)

    This issue happens only on CI:CD, I never get it locally when running unit tests on my machine. Even then, we don't get this for every build. It happens randomly.

    We're using Angular version 13.2.6 and the following Karma versions: "karma": "~6.3.17", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.0.3", "karma-jasmine": "~4.0.1", "karma-jasmine-html-reporter": "^1.7.0", "karma-scss-preprocessor": "^4.0.0",

    What are some potential root causes we can troubleshoot to better understand why the unit tests randomly disconnect. Please advise. Thank you!

    opened by eberhak 3
  • Angular 14 karma gets stuck after executing tests on Azure Devops Linux Build Agents using chrome Headless resulting in stuck pipeline

    Angular 14 karma gets stuck after executing tests on Azure Devops Linux Build Agents using chrome Headless resulting in stuck pipeline

    Angular 14 karma gets stuck after executing tests on Azure Devops Linux Build Agents using chrome Headless resulting in stuck pipeline. This issue only seems to happen when running chrome headless on a linux based azure devops agent but not on windows.

    Karma versions and dependency versions: "karma": "~6.4.1", "karma-chrome-launcher": "~3.1.1", "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.0.0",

    Karma configuration: // 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'], 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: { verboseDeprecations: true // 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 }, clearContext: false // leave Jasmine Spec Runner output visible in browser }, jasmineHtmlReporter: { suppressAll: true // removes the duplicated traces }, coverageReporter: { dir: require('path').join(__dirname, './coverage/libraries'), subdir: '.', reporters: [{ type: 'html' }, { type: 'text-summary' }] }, reporters: ['progress', 'kjhtml'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: false, browsers: ['Chrome'], singleRun: true, captureTimeout: 6000, restartOnFileChange: true }); };

    In all runs the tests seem to finish but the pipeline hangs:

    LOG: 'sidenavtabs=', [] Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 15 of 49 (skipped 1) SUCCESS (0 secs / 0.335 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 16 of 49 (skipped 1) SUCCESS (0 secs / 0.343 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 17 of 49 (skipped 1) SUCCESS (0 secs / 0.346 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 18 of 49 (skipped 1) SUCCESS (0 secs / 0.35 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 19 of 49 (skipped 1) SUCCESS (0 secs / 0.351 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 20 of 49 (skipped 1) SUCCESS (0 secs / 0.353 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 21 of 49 (skipped 1) SUCCESS (0 secs / 0.356 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 22 of 49 (skipped 1) SUCCESS (0 secs / 0.362 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 23 of 49 (skipped 2) SUCCESS (0 secs / 0.364 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 24 of 49 (skipped 3) SUCCESS (0 secs / 0.372 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 25 of 49 (skipped 3) SUCCESS (0 secs / 0.375 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 26 of 49 (skipped 3) SUCCESS (0 secs / 0.377 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 27 of 49 (skipped 3) SUCCESS (0 secs / 0.377 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 28 of 49 (skipped 3) SUCCESS (0 secs / 0.38 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 29 of 49 (skipped 3) SUCCESS (0 secs / 0.383 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 30 of 49 (skipped 3) SUCCESS (0 secs / 0.389 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 31 of 49 (skipped 3) SUCCESS (0 secs / 0.395 secs) LOG: [] Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 31 of 49 (skipped 3) SUCCESS (0 secs / 0.395 secs) LOG: [] Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 32 of 49 (skipped 3) SUCCESS (0 secs / 0.399 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 33 of 49 (skipped 3) SUCCESS (0 secs / 0.406 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 34 of 49 (skipped 3) SUCCESS (0 secs / 0.409 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 35 of 49 (skipped 3) SUCCESS (0 secs / 0.415 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 36 of 49 (skipped 3) SUCCESS (0 secs / 0.424 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 37 of 49 (skipped 3) SUCCESS (0 secs / 0.427 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 38 of 49 (skipped 3) SUCCESS (0 secs / 0.438 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 39 of 49 (skipped 3) SUCCESS (0 secs / 0.448 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 40 of 49 (skipped 3) SUCCESS (0 secs / 0.453 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 41 of 49 (skipped 3) SUCCESS (0 secs / 0.46 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 42 of 49 (skipped 3) SUCCESS (0 secs / 0.462 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 43 of 49 (skipped 3) SUCCESS (0 secs / 0.469 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 44 of 49 (skipped 4) SUCCESS (0 secs / 0.479 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 45 of 49 (skipped 4) SUCCESS (0 secs / 0.485 secs) Chrome Headless 103.0.5060.134 (Linux x86_64): Executed 45 of 49 (skipped 4) SUCCESS (0.007 secs / 0.485 secs) TOTAL: 45 SUCCESS

    If we run it directly on the linux host it seems to exit fine, this only seems to happen when run inside a pipeline.

    We have reached out to Microsoft who have recreated the issue but claim it is an issue wiht karma hanging rather than an Azure DevOps issue:

    "We have update from PG. This appears to be a 3rd party issue and not a devops issue.

    • Confirmed problem happens hosted or self hosted
    • There are reports of npm test with Karma 14 hanging https://github.com/karma-runner/karma/issues/3803
    • "kill -9 npm" will allow the pipeline to proceed
    • This proves that the issue is not on the devops side and is due to the 3rd party not giving our agents the command to stop the script which is also common on other platform agents.

    We suggest reaching out to the karma team to resolve this."

    opened by shaneohanlon-EN0113 0
Releases(v6.4.1)
Owner
Karma
The Spectacular Test Runner for JavaScript.
Karma
A next-generation code testing stack for JavaScript.

Intern Software testing for humans ⚠️ This documentation is for the development version of Intern. For the current release version, go here. Intern is

Intern: next-gen JavaScript testing 4.4k Jan 7, 2023
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
A leetcode workspace template with test case runner for JavaScript/TypeScript programmers.

leetcode-typescript-workspace English | 简体中文 A vscode workspace template with test case runner script for JavaScript/TypeScript programmers using exte

null 10 Dec 13, 2022
A simple tap test runner that can be used by any javascript interpreter.

just-tap A simple tap test runner that can be used in any client/server javascript app. Installation npm install --save-dev just-tap Usage import cre

Mark Wylde 58 Nov 7, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Test runner based on Tape and Browserify

prova Node & Browser Test runner based on Tape and Browserify. Screencasts: node.gif, browser.gif, both.gif, headless browser Slides: slides.com/azer/

Azer Koçulu 335 Oct 28, 2022
Node.js test runner that lets you develop with confidence 🚀

AVA is a test runner for Node.js with a concise API, detailed error output, embrace of new language features and process isolation that lets you devel

AVA 20.2k Jan 1, 2023
A new zero-config test runner for the true minimalists

Why User-friendly - zero-config, no API to learn, simple conventions Extremely lighweight - only 40 lines of code and no dependencies Super fast - wit

null 680 Dec 20, 2022
A low-feature, dependency-free and performant test runner inspired by Rust and Deno

minitest A low-feature, dependency-free and performant test runner inspired by Rust and Deno Simplicity: Use the mt test runner with the test function

Sondre Aasemoen 4 Nov 12, 2022
Grunt: The JavaScript Task Runner

Grunt: The JavaScript Task Runner Documentation Visit the gruntjs.com website for all the things. Support / Contributing Before you make an issue, ple

grunt 12.2k Dec 31, 2022
:red_circle: Functional task runner for Node.js

start ⚠️ Project has been transferred to NexTools metarepo functional – in all senses fast – parallelism and concurrency shareable – presets as publis

Kir Belevich 477 Dec 15, 2022
🏆 2nd Runner Up 🏆 at Vividthata A Blend of ideas By NIT Hamirpur

Index Problem Statement Solution Proposed How it Works Challenges we faced Running Locally Demonstration Glimpse Problem Statement It is often the cas

null 3 Nov 22, 2022
Dead Simple Postgres Data Viewer and Query Runner

Dead Simple Postgres Data Viewer and Query Runner Environment Variables GITHUB_CLIENT_ID Github Client ID of the Oauth Application for protecting your

Mahesh C. Regmi 7 Aug 22, 2022
A Jest runner that runs tests directly in bare Node.js, without virtualizing the environment.

jest-light-runner A Jest runner that runs tests directly in bare Node.js, without virtualizing the environment. Comparison with the default Jest runne

Nicolò Ribaudo 193 Dec 12, 2022
HTML5 Runner Game Made With Phaser.

"Hurry up Runner!" The Tunner Game "Hurry up!" Is A Small Funny Game Made With Phaser 3. This Game Is About Ordinary Salaryman That Hurries For His Jo

Abhay 3 Sep 26, 2022
Jester is a test-generation tool to create integration test code.

Code Generator for Integration Tests Introduction Welcome to Jester: An easy-to-use web application that helps you create and implement integration te

OSLabs Beta 54 Dec 12, 2022
Test spies, stubs and mocks for JavaScript.

Sinon.JS Standalone and test framework agnostic JavaScript test spies, stubs and mocks (pronounced "sigh-non", named after Sinon, the warrior). Compat

Sinon.JS 9.2k Jan 4, 2023
☕️ simple, flexible, fun javascript test framework for node.js & the browser

☕️ Simple, flexible, fun JavaScript test framework for Node.js & The Browser ☕️ Links Documentation Release Notes / History / Changes Code of Conduct

Mocha 21.8k Dec 30, 2022
In this project I write the test for several functions and used the TDD with Jest and JavaScript.

JavaScript-Testing-with-Jest npm init -y npm install --save-dev jest Once installed, you should see it in already created Json file Change Jest Script

Ben Kiboma Omayio 2 Jun 11, 2022