1 | # karma-chrome-launcher
|
2 |
|
3 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma-chrome-launcher)
|
4 | [![npm version](https://img.shields.io/npm/v/karma-chrome-launcher.svg?style=flat-square)](https://www.npmjs.com/package/karma-chrome-launcher) [![npm downloads](https://img.shields.io/npm/dm/karma-chrome-launcher.svg?style=flat-square)](https://www.npmjs.com/package/karma-chrome-launcher)
|
5 |
|
6 | [![Build Status](https://img.shields.io/travis/karma-runner/karma-chrome-launcher/master.svg?style=flat-square)](https://travis-ci.org/karma-runner/karma-chrome-launcher) [![Dependency Status](https://img.shields.io/david/karma-runner/karma-chrome-launcher.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-chrome-launcher) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma-chrome-launcher.svg?style=flat-square)](https://david-dm.org/karma-runner/karma-chrome-launcher#info=devDependencies)
|
7 |
|
8 | > Launcher for Google Chrome, Google Chrome Canary and Google Chromium.
|
9 |
|
10 | ## Installation
|
11 |
|
12 | The easiest way is to keep `karma-chrome-launcher` as a devDependency in your `package.json`,
|
13 | by running
|
14 |
|
15 | ```bash
|
16 | $ npm i -D karma-chrome-launcher
|
17 | ```
|
18 |
|
19 | ## Configuration
|
20 |
|
21 | ```js
|
22 | // karma.conf.js
|
23 | module.exports = function(config) {
|
24 | config.set({
|
25 | browsers: ['Chrome', 'Chrome_without_security'], // You may use 'ChromeCanary', 'Chromium' or any other supported browser
|
26 |
|
27 | // you can define custom flags
|
28 | customLaunchers: {
|
29 | Chrome_without_security: {
|
30 | base: 'Chrome',
|
31 | flags: ['--disable-web-security', '--disable-site-isolation-trials']
|
32 | }
|
33 | }
|
34 | })
|
35 | }
|
36 | ```
|
37 |
|
38 | The `--user-data-dir` is set to a temporary directory but can be overridden on a custom launcher as shown below.
|
39 | One reason to do this is to have a permanent Chrome user data directory inside the project directory to be able to
|
40 | install plugins there (e.g. JetBrains IDE Support plugin).
|
41 |
|
42 | ```js
|
43 | customLaunchers: {
|
44 | Chrome_with_debugging: {
|
45 | base: 'Chrome',
|
46 | chromeDataDir: path.resolve(__dirname, '.chrome')
|
47 | }
|
48 | }
|
49 | ```
|
50 |
|
51 | You can pass list of browsers as a CLI argument too:
|
52 |
|
53 | ```bash
|
54 | $ karma start --browsers Chrome,Chrome_without_security
|
55 | ```
|
56 |
|
57 | ## Headless Chromium with Puppeteer
|
58 |
|
59 | The Chrome DevTools team created [Puppeteer](https://github.com/GoogleChrome/puppeteer) - it will automatically install Chromium for all
|
60 | platforms and contains everything you need to run it from within your CI.
|
61 |
|
62 | ### Available Browsers
|
63 | *Note: Headless mode requires a browser version >= 59*
|
64 |
|
65 | - Chrome (CHROME_BIN)
|
66 | - ChromeHeadless (CHROME_BIN)
|
67 | - Chromium (CHROMIUM_BIN)
|
68 | - ChromiumHeadless (CHROMIUM_BIN)
|
69 | - ChromeCanary (CHROME_CANARY_BIN)
|
70 | - ChromeCanaryHeadless (CHROME_CANARY_BIN)
|
71 | - Dartium (DARTIUM_BIN)
|
72 |
|
73 | #### Usage
|
74 | ```bash
|
75 | $ npm i -D puppeteer karma-chrome-launcher
|
76 | ```
|
77 |
|
78 | ```js
|
79 | // karma.conf.js
|
80 | process.env.CHROME_BIN = require('puppeteer').executablePath()
|
81 |
|
82 | module.exports = function(config) {
|
83 | config.set({
|
84 | browsers: ['ChromeHeadless']
|
85 | })
|
86 | }
|
87 | ```
|
88 |
|
89 | ----
|
90 |
|
91 | For more information on Karma see the [homepage].
|
92 |
|
93 | [homepage]: https://karma-runner.github.io
|