-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
60 lines (57 loc) · 1.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Service plugin that allows running unit tests with `ava`.
* @module vue-cli-plugin-unit-ava
* @see {@link https://cli.vuejs.org/dev-guide/plugin-dev.html#service-plugin}
*/
const {
execa
} = require('@vue/cli-shared-utils')
/**
* @external pluginApi
* @see {@link https://cli.vuejs.org/dev-guide/plugin-api.html}
*/
/**
* vue-cli plugin setup function.
* @param {pluginApi} api
*/
module.exports = (api, options) => {
api.registerCommand('test:unit', {
description: 'run unit tests with ava',
usage: 'vue-cli-service test:unit [options] [<file|directory|glob> ...]',
options: {
'--watch, -w': 'Re-run tests when tests and source files change',
'--match, -m': 'Only run tests with matching title (Can be repeated)',
'--update-snapshots, -u': 'Update snapshots',
'--fail-fast': 'Stop after first test failure',
'--timeout, -T': 'Set global timeout',
'--serial, -s': 'Run tests serially',
'--concurrency, -c': 'Max number of test files running at the same time (Default: CPU cores)',
'--verbose, -v': 'Enable verbose output',
'--tap, -t': 'Generate TAP output',
'--color': 'Force color output',
'--no-color': 'Disable color output'
},
details: `See
* https://github.com/avajs/ava
* https://github.com/avajs/ava/blob/master/docs/05-command-line.md`
}, async (args, rawArgs) => {
return new Promise((resolve, reject) => {
const child = execa('ava', rawArgs, { stdio: 'inherit' })
child.on('error', reject)
child.on('exit', code => {
if (code !== 0) {
reject(new Error(`ava exited with code ${code}`))
} else {
resolve()
}
})
})
})
}
/**
* Plugin default modes
* @type {Object}
*/
module.exports.defaultModes = {
'test:unit': 'test'
}