1 | 'use strict'
|
2 |
|
3 | const EPILOG = `
|
4 | By default browser tests run in Chrome headless.
|
5 | Browser testing with Karma supports options forwarding with '--' for more info check https://karma-runner.github.io/3.0/config/configuration-file.html
|
6 | `
|
7 |
|
8 | module.exports = {
|
9 | command: 'test',
|
10 | desc: 'Test your code in different environments',
|
11 | builder: (yargs) => {
|
12 | yargs
|
13 | .epilog(EPILOG)
|
14 | .example('aegir test -t webworker', 'Run tests in the browser with Karma inside a webworker.')
|
15 | .example('aegir test -t browser -- --browsers Firefox,Chrome,Safari', 'Tell Karma to run tests in several browsers at the same time.')
|
16 | .example('aegir test -w -t browser -- --browsers Chrome', 'Debug tests with watch mode and tell Karma to open Chrome in a non-headless mode.')
|
17 | .example(
|
18 | 'aegir test -t electron-renderer -- --interactive',
|
19 | 'Debug electron renderer test with a persistent window.'
|
20 | )
|
21 | .options({
|
22 | 100: {
|
23 | describe: 'Check coverage and validate 100% was covered.',
|
24 | type: 'boolean',
|
25 | default: false
|
26 | },
|
27 | target: {
|
28 | alias: 't',
|
29 | describe: 'In which target environment to execute the tests',
|
30 | type: 'array',
|
31 | choices: ['node', 'browser', 'webworker', 'electron-main', 'electron-renderer'],
|
32 | default: ['node', 'browser', 'webworker']
|
33 | },
|
34 | verbose: {
|
35 | describe: 'Print verbose test output',
|
36 | type: 'boolean',
|
37 | default: false
|
38 | },
|
39 | watch: {
|
40 | alias: 'w',
|
41 | describe: 'Watch files for changes and rerun tests',
|
42 | type: 'boolean',
|
43 | default: false
|
44 | },
|
45 | files: {
|
46 | alias: 'f',
|
47 | describe: 'Custom globs for files to test',
|
48 | type: 'array',
|
49 | default: []
|
50 | },
|
51 | parallel: {
|
52 | alias: 'p',
|
53 | describe: 'Run tests in parallel (only available in node)',
|
54 | type: 'boolean',
|
55 | default: true
|
56 | },
|
57 | timeout: {
|
58 | describe: 'The default time a single test has to run',
|
59 | type: 'number',
|
60 | default: 5000
|
61 | },
|
62 | exit: {
|
63 | describe: 'Force shutdown of the event loop after test run: mocha will call process.exit',
|
64 | type: 'boolean',
|
65 | default: true
|
66 | },
|
67 | colors: {
|
68 | describe: 'Enable colors on output (only available in node runs)',
|
69 | type: 'boolean',
|
70 | default: true
|
71 | },
|
72 | grep: {
|
73 | alias: 'g',
|
74 | type: 'string',
|
75 | describe: 'Limit tests to those whose names match given pattern'
|
76 | },
|
77 | bail: {
|
78 | alias: 'b',
|
79 | describe: 'Mocha should bail once a test fails',
|
80 | type: 'boolean',
|
81 | default: false
|
82 | },
|
83 | progress: {
|
84 | describe: 'Use progress reporters on mocha and karma',
|
85 | type: 'boolean',
|
86 | default: false
|
87 | }
|
88 | })
|
89 | },
|
90 | handler (argv) {
|
91 | const test = require('../src/test')
|
92 | return test.run(argv)
|
93 | }
|
94 | }
|