UNPKG

1.49 kBMarkdownView Raw
1# @poi/plugin-karma
2
3Automatic (headless) browser testing with [Karma](https://karma-runner.github.io/latest/index.html).
4
5## Introduction
6
7This 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
12yarn add @poi/plugin-karma --dev
13```
14
15## How to use
16
17In your `poi.config.js`:
18
19```js
20module.exports = {
21 plugins: [
22 {
23 resolve: '@poi/plugin-karma'
24 }
25 ]
26}
27```
28
29This plugin injected a new command to Poi CLI: `poi test:unit` which is a command running in Poi's `test` mode.
30
31To run it easier, you can configure this in npm scripts:
32
33```json
34{
35 "name": "my-project",
36 "scripts": {
37 "test": "poi test:unit",
38 "build": "poi --prod",
39 "start": "poi --serve"
40 },
41 "devDependencies": {
42 "poi": "^12.0.0"
43 }
44}
45```
46
47Now you can run `npm test` instead.
48
49### Test File Patterns
50
51By 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
54poi test:unit "**/*.spec.coffee"
55```
56
57### Coverage Report
58
59Use `--coverage` flag to show code coverage and generate coverage report to `./coverage` folder.
60
61### Watching Files
62
63Use `--watch` flag to watch test files.
64
65### Running on CI
66
67To run your tests in Continuous Integration Platforms like CircleCI, you will need `Chrome` installed in your test environment.