-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
config.js
54 lines (47 loc) 路 1.77 KB
/
config.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
'use strict';
const fs = require('fs');
const path = require('path');
const {test} = require('tap');
const execa = require('execa');
const tempy = require('tempy');
const {execCli} = require('../helper/cli');
test('formats errors from ava.config.js', t => {
execCli(['es2015.js'], {dirname: 'fixture/load-config/throws'}, (err, stdout, stderr) => {
t.ok(err);
const lines = stderr.split('\n');
t.is(lines[0], '');
t.match(lines[1], /Error loading ava\.config\.js:/);
t.is(lines[2], '');
t.match(lines[3], /ava\.config\.js/);
t.match(lines[4], /foo/);
t.end();
});
});
test('pkg-conf(resolve-dir): works as expected when run from the package.json directory', t => {
execCli(['--verbose'], {dirname: 'fixture/pkg-conf/resolve-dir'}, (err, stdout) => {
t.ifError(err);
t.match(stdout, /dir-a-base-1/);
t.match(stdout, /dir-a-base-2/);
t.notMatch(stdout, /dir-a-wrapper/);
t.notMatch(stdout, /dir-a-wrapper/);
t.end();
});
});
test('pkg-conf(resolve-dir): resolves tests from the package.json dir if none are specified on cli', t => {
execCli(['--verbose'], {dirname: 'fixture/pkg-conf/resolve-dir/dir-a-wrapper'}, (err, stdout) => {
t.ifError(err);
t.match(stdout, /dir-a-base-1/);
t.match(stdout, /dir-a-base-2/);
t.notMatch(stdout, /dir-a-wrapper/);
t.notMatch(stdout, /dir-a-wrapper/);
t.end();
});
});
test('use current working directory if `package.json` is not found', () => {
const cwd = tempy.directory();
const testFilePath = path.join(cwd, 'test.js');
const cliPath = require.resolve('../../cli.js');
const avaPath = require.resolve('../../');
fs.writeFileSync(testFilePath, `const test = require(${JSON.stringify(avaPath)});\ntest('test', t => { t.pass(); });`);
return execa(process.execPath, [cliPath], {cwd, env: {AVA_FORCE_CI: 'ci'}});
});