Skip to content

Commit

Permalink
test(cli): test the functionality for rc files
Browse files Browse the repository at this point in the history
  • Loading branch information
manuth committed Apr 24, 2023
1 parent e76a0df commit f131e9a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./extends.json"
}
35 changes: 27 additions & 8 deletions test/integration/options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,39 @@ var path = require('path');
var loadOptions = require('../../lib/cli/options').loadOptions;

describe('options', function () {
it('Should support extended options', function () {
var configDir = path.join(
__dirname,
'fixtures',
'config',
'mocharc-extended'
);
var workingDirectory;
const workspaceDir = path.join(
__dirname,
'fixtures',
'config',
'mocharc-extended'
);

beforeEach(function () {
workingDirectory = process.cwd();
process.chdir(workspaceDir);
});

afterEach(function () {
process.chdir(workingDirectory);
});

it('Should support extended options using --config parameter', function () {
var extended = loadOptions([
'--config',
path.join(configDir, 'extends.json')
path.join(workspaceDir, 'extends.json')
]);
expect(extended.require, 'to equal', ['foo', 'bar']);
expect(extended.bail, 'to equal', true);
expect(extended.reporter, 'to equal', 'html');
expect(extended.slow, 'to equal', 30);
});

it('Should support extended options using rc file', function () {
var extended = loadOptions([]);
expect(extended.require, 'to equal', ['foo', 'bar']);
expect(extended.bail, 'to equal', true);
expect(extended.reporter, 'to equal', 'html');
expect(extended.slow, 'to equal', 30);
});
});

0 comments on commit f131e9a

Please sign in to comment.