1 | ;
|
2 | const path = require('path');
|
3 | const chalk = require('chalk'); // Use default Chalk instance.
|
4 |
|
5 | // Check if the test is being run without AVA cli
|
6 | const isForked = typeof process.send === 'function';
|
7 | if (!isForked) {
|
8 | if (process.argv[1]) {
|
9 | const fp = path.relative('.', process.argv[1]);
|
10 |
|
11 | console.log();
|
12 | console.error(`Test files must be run with the AVA CLI:\n\n ${chalk.grey.dim('$')} ${chalk.cyan('ava ' + fp)}\n`);
|
13 |
|
14 | process.exit(1); // eslint-disable-line unicorn/no-process-exit
|
15 | } else {
|
16 | throw new Error('The ’ava’ module can only be imported in test files');
|
17 | }
|
18 | }
|