1 | # @poi/plugin-karma
|
2 |
|
3 | Automatic (headless) browser testing with [Karma](https://karma-runner.github.io/latest/index.html).
|
4 |
|
5 | ## Introduction
|
6 |
|
7 | This plugin pre-configures [Karma](https://karma-runner.github.io/), [Jasmine](https://jasmine.github.io/) for you so that you can run the tests without any configurations.
|
8 |
|
9 | ## Install
|
10 |
|
11 | ```bash
|
12 | yarn add @poi/plugin-karma --dev
|
13 | ```
|
14 |
|
15 | ## How to use
|
16 |
|
17 | In your `poi.config.js`:
|
18 |
|
19 | ```js
|
20 | module.exports = {
|
21 | plugins: [
|
22 | {
|
23 | resolve: '@poi/plugin-karma'
|
24 | }
|
25 | ]
|
26 | }
|
27 | ```
|
28 |
|
29 | This plugin injected a new command to Poi CLI: `poi karma`, however you should always use `poi karma --test` to run your tests in `test` mode.
|
30 |
|
31 | To run it easier, you can configure this in npm scripts:
|
32 |
|
33 | ```json
|
34 | {
|
35 | "name": "my-project",
|
36 | "scripts": {
|
37 | "test": "poi karma --test",
|
38 | "build": "poi --prod",
|
39 | "start": "poi --serve"
|
40 | },
|
41 | "devDependencies": {
|
42 | "poi": "^12.0.0"
|
43 | }
|
44 | }
|
45 | ```
|
46 |
|
47 | Now you can run `npm test` instead.
|
48 |
|
49 | ### Test File Patterns
|
50 |
|
51 | By default this plugin use `**/*.{test,spec}.{js,ts}` (excluded `node_modules`) as test files, you can change this to any minimatch pattern (note the quotes to avoid shell expansion):
|
52 |
|
53 | ```bash
|
54 | poi karma "**/*.spec.coffee" --test
|
55 | ```
|
56 |
|
57 | ### Coverage Report
|
58 |
|
59 | Use `--coverage` flag to show code coverage and generate coverage report to `./coverage` folder.
|
60 |
|
61 | ### Watching Files
|
62 |
|
63 | Use `--watch` flag to watch test files.
|
64 |
|
65 | ### Running on CI
|
66 |
|
67 | To run your tests in Continuous Integration Platforms like CircleCI, you will need `Chrome` installed in your test environment.
|