Skip to content

Commit f131e9a

Browse files
committed
test(cli): test the functionality for rc files
1 parent e76a0df commit f131e9a

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./extends.json"
3+
}

test/integration/options.spec.js

+27-8
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,39 @@ var path = require('path');
44
var loadOptions = require('../../lib/cli/options').loadOptions;
55

66
describe('options', function () {
7-
it('Should support extended options', function () {
8-
var configDir = path.join(
9-
__dirname,
10-
'fixtures',
11-
'config',
12-
'mocharc-extended'
13-
);
7+
var workingDirectory;
8+
const workspaceDir = path.join(
9+
__dirname,
10+
'fixtures',
11+
'config',
12+
'mocharc-extended'
13+
);
14+
15+
beforeEach(function () {
16+
workingDirectory = process.cwd();
17+
process.chdir(workspaceDir);
18+
});
19+
20+
afterEach(function () {
21+
process.chdir(workingDirectory);
22+
});
23+
24+
it('Should support extended options using --config parameter', function () {
1425
var extended = loadOptions([
1526
'--config',
16-
path.join(configDir, 'extends.json')
27+
path.join(workspaceDir, 'extends.json')
1728
]);
1829
expect(extended.require, 'to equal', ['foo', 'bar']);
1930
expect(extended.bail, 'to equal', true);
2031
expect(extended.reporter, 'to equal', 'html');
2132
expect(extended.slow, 'to equal', 30);
2233
});
34+
35+
it('Should support extended options using rc file', function () {
36+
var extended = loadOptions([]);
37+
expect(extended.require, 'to equal', ['foo', 'bar']);
38+
expect(extended.bail, 'to equal', true);
39+
expect(extended.reporter, 'to equal', 'html');
40+
expect(extended.slow, 'to equal', 30);
41+
});
2342
});

0 commit comments

Comments
 (0)