Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

karma-phantomjs-launcher

karma-runner452.4kMITdeprecated1.0.4

PhantomJS development have stopped, use puppeteer or similar

A Karma plugin. Launcher for PhantomJS.

karma-plugin, karma-launcher, phantomjs

readme

karma-phantomjs-launcher

js-standard-style npm version npm downloads

Build Status Dependency Status devDependency Status

Launcher for PhantomJS.

Installation

The easiest way is to keep karma-phantomjs-launcher as a devDependency in your package.json, by running

$ npm install --save-dev karma-phantomjs-launcher

Configuration

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

    // you can define custom flags
    customLaunchers: {
      'PhantomJS_custom': {
        base: 'PhantomJS',
        options: {
          windowName: 'my-window',
          settings: {
            webSecurityEnabled: false
          },
        },
        flags: ['--load-images=true'],
        debug: true
      }
    },

    phantomjsLauncher: {
      // Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
      exitOnResourceError: true
    }
  })
}

The options attribute allows you to initialize properties on the phantomjs page object, so

options: {
  windowName: 'my-window',
  settings: {
    webSecurityEnabled: false
  },
}

is equivalent to:

var webPage = require('webpage')
var page = webPage.create()

page.windowName = 'my-window'
page.settings.webSecurityEnabled = false

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

$ karma start --browsers PhantomJS_custom

If you set the debug option to true, you will be instructed to launch a web browser to bring up the debugger. Note that you will want to put debugger; statements in your JavaScript to hit breakpoints. You should be able to put breakpoints in both your test code and your client code. Note that the debug option automatically adds the --remote-debugger-port=9000 and --remote-debugger-autorun=yes switches to PhantomJS.


For more information on Karma see the homepage.

changelog

<a name"1.0.4">

1.0.4 (2017-03-10)

Bug Fixes

<a name"1.0.3">

1.0.3 (2017-03-10)

Bug Fixes

  • path issue with phantomjs and phantomjs-prebuilt (482eba50)

<a name"1.0.2">

1.0.2 (2016-08-31)

Bug Fixes

  • incorrect phantomjs path calculation (faa7474e)

<a name"1.0.1">

1.0.1 (2016-06-23)

Bug Fixes

  • version-reset: set version back to 1.0 (9b0f5e34)

<a name"1.0.0">

1.0.0 (2016-01-28)

Bug Fixes

  • replace deprecated nvm version identifier with the proper one (9f9e0e2d)
  • test on Node v4 instead of ancient v0.4 (ad1aad5f)
  • use phantomjs-prebuilt instead of deprecated phantomjs (5844941a)

<a name"0.2.3">

0.2.3 (2016-01-04)

Bug Fixes

<a name"0.2.2">

0.2.2 (2015-12-24)

Bug Fixes

  • pass PhantomJS script as the first cmd-line argument (1c195c6b)
  • do not duplicate cmd-line flags on repeated PhantomJS runs (76228f18)

<a name"0.2.1">

0.2.1 (2015-08-05)

Bug Fixes

  • ensure console output from phantomjs is available in karma debug logs (eed281b5)

<a name"0.2.0">

0.2.0 (2015-05-29)

Bug Fixes

  • npm: Make .npmignore more sensible to dot files (1322a89d, closes #68)

Features

  • Move phantomjs to peerDeps, #37, #42, #56 (a0f399de, closes #25)
  • Support option for phantom to exit on ResourceError (2b90c6b9)
  • debug option (c6dfe786)