@@ -4,20 +4,39 @@ var path = require('path');
4
4
var loadOptions = require ( '../../lib/cli/options' ) . loadOptions ;
5
5
6
6
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 ( ) {
14
25
var extended = loadOptions ( [
15
26
'--config' ,
16
- path . join ( configDir , 'extends.json' )
27
+ path . join ( workspaceDir , 'extends.json' )
17
28
] ) ;
18
29
expect ( extended . require , 'to equal' , [ 'foo' , 'bar' ] ) ;
19
30
expect ( extended . bail , 'to equal' , true ) ;
20
31
expect ( extended . reporter , 'to equal' , 'html' ) ;
21
32
expect ( extended . slow , 'to equal' , 30 ) ;
22
33
} ) ;
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
+ } ) ;
23
42
} ) ;
0 commit comments