18.0.0 • Published 6 months ago

karma-jsdom-launcher v18.0.0

Weekly downloads
8,539
License
MIT
Repository
github
Last release
6 months ago

karma-jsdom-launcher

Launcher for jsdom.

Installation

npm install karma-jsdom-launcher --save-dev

NOTE: karma and jsdom are peerDependencies of this module. If you haven't install them, run

npm install karma-jsdom-launcher jsdom karma --save-dev

to install all your dependencies.

Configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
    browsers: ['jsdom'],
  });
};

You can pass list of browsers as a CLI argument too:

karma start --browsers jsdom

You can pass options directly to jsdom as shown below. See jsdom's own documentation for all supported options.

// karma.conf.js
const jsdom = require("jsdom");

module.exports = function(config) {
  config.set({
    browsers: ['jsdom'],

    jsdomLauncher: {
      jsdom: {
        resources: new jsdom.ResourceLoader({
          userAgent: "foobar",
        })
      }
    }
  });
};

FAQ

I am using Gulp and the test suite is not exiting

This occurs due to lingering event handlers and it is currently an unsolved issue. Meanwhile you have to explicitly exit the process yourself. This can be done by not passing a callback to Karma.Server or by invoking process.exit(), as shown below.

var gulp = require('gulp');
var Server = require('karma').Server;

gulp.task('test', function () {
  new Server({
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
  }).start();
});
var gulp = require('gulp');
var Server = require('karma').Server;

gulp.task('test', function (done) {
  new Server({
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
  }, function (exitCode) {
    done();
    process.exit(exitCode);
  }).start();
});

I am using Angular CLI and the test suite hangs indefinitely

You might experience a known issue where Karma attempts to perform a synchronous request, resulting in a deadlock. Disable use of source-maps in your tests, as shown below.

// angular.json

{
  ...
        "test": {
          "options": {
            "sourceMap": false

For more information on Karma see the homepage.

18.0.0

6 months ago

17.0.0

1 year ago

16.0.0

2 years ago

15.0.0

2 years ago

14.0.0

3 years ago

13.0.0

3 years ago

12.0.0

4 years ago

11.0.0

4 years ago

10.0.0

4 years ago

9.0.0

4 years ago

8.0.2

5 years ago

8.0.1

5 years ago

8.0.0

6 years ago

7.1.1

6 years ago

7.1.0

6 years ago

7.0.0

7 years ago

7.0.0-rc1

7 years ago

6.1.5

7 years ago

6.1.4

7 years ago

6.1.3

7 years ago

6.1.2

8 years ago

6.1.1

8 years ago

6.1.0

8 years ago

6.0.0

8 years ago

5.0.0

9 years ago

4.0.0

9 years ago

3.0.0

9 years ago

2.0.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago