1
1
'use strict' ;
2
2
3
- const { run } = require ( '../utils/test-utils ' ) ;
3
+ const path = require ( 'path ' ) ;
4
4
5
- describe ( 'basic info usage' , ( ) => {
5
+ const { run } = require ( '../../utils/test-utils' ) ;
6
+
7
+ describe ( "'configtest' command with the configuration path option" , ( ) => {
6
8
it ( 'should validate webpack config successfully' , ( ) => {
7
- const { exitCode, stderr, stdout } = run ( __dirname , [ 'configtest' , './webpack .config.js' ] , false ) ;
9
+ const { exitCode, stderr, stdout } = run ( __dirname , [ 'configtest' , './basic .config.js' ] , false ) ;
8
10
9
11
expect ( exitCode ) . toBe ( 0 ) ;
10
12
expect ( stderr ) . toBeFalsy ( ) ;
13
+ expect ( stdout ) . toContain ( `Validate '${ path . resolve ( __dirname , 'basic.config.js' ) } '.` ) ;
11
14
expect ( stdout ) . toContain ( 'There are no validation errors in the given webpack configuration.' ) ;
12
15
} ) ;
13
16
@@ -17,7 +20,7 @@ describe('basic info usage', () => {
17
20
expect ( exitCode ) . toBe ( 2 ) ;
18
21
expect ( stderr ) . toContain ( 'Invalid configuration object.' ) ;
19
22
expect ( stderr ) . toContain ( 'configuration.mode should be one of these:' ) ;
20
- expect ( stdout ) . toBeFalsy ( ) ;
23
+ expect ( stdout ) . toContain ( `Validate ' ${ path . resolve ( __dirname , 'error.config.js' ) } '.` ) ;
21
24
} ) ;
22
25
23
26
it ( 'should throw syntax error' , ( ) => {
@@ -34,7 +37,7 @@ describe('basic info usage', () => {
34
37
expect ( exitCode ) . toBe ( 2 ) ;
35
38
expect ( stderr ) . toContain ( 'Invalid configuration object.' ) ;
36
39
expect ( stderr ) . toContain ( 'configuration.mode should be one of these:' ) ;
37
- expect ( stdout ) . toBeFalsy ( ) ;
40
+ expect ( stdout ) . toContain ( `Validate ' ${ path . resolve ( __dirname , 'error.config.js' ) } '.` ) ;
38
41
} ) ;
39
42
40
43
it ( 'should throw error if configuration does not exist' , ( ) => {
@@ -44,12 +47,4 @@ describe('basic info usage', () => {
44
47
expect ( stderr ) . toContain ( `The specified config file doesn't exist` ) ;
45
48
expect ( stdout ) . toBeFalsy ( ) ;
46
49
} ) ;
47
-
48
- it ( 'should throw error if no configuration was provided' , ( ) => {
49
- const { exitCode, stderr, stdout } = run ( __dirname , [ 'configtest' ] , false ) ;
50
-
51
- expect ( exitCode ) . toBe ( 2 ) ;
52
- expect ( stderr ) . toContain ( `error: missing required argument 'config-path'` ) ;
53
- expect ( stdout ) . toBeFalsy ( ) ;
54
- } ) ;
55
50
} ) ;
0 commit comments