@@ -6,6 +6,7 @@ const internalIp = require('internal-ip');
6
6
const stripAnsi = require ( 'strip-ansi' ) ;
7
7
const { testBin, normalizeStderr } = require ( '../helpers/test-bin' ) ;
8
8
9
+ const isMacOS = process . platform === 'darwin' ;
9
10
const localIPv4 = internalIp . v4 . sync ( ) ;
10
11
const localIPv6 = internalIp . v6 . sync ( ) ;
11
12
@@ -93,44 +94,45 @@ describe('CLI', () => {
93
94
} ) ;
94
95
} ) ;
95
96
96
- describe ( 'bonjour option' , ( ) => { } ) ;
97
- it ( '--bonjour' , ( done ) => {
98
- testBin ( '--bonjour' )
99
- . then ( ( output ) => {
100
- expect ( output . exitCode ) . toEqual ( 0 ) ;
101
- expect (
102
- normalizeStderr ( output . stderr , { ipv6 : true } )
103
- ) . toMatchSnapshot ( ) ;
97
+ describe ( 'bonjour option' , ( ) => {
98
+ it ( '--bonjour' , ( done ) => {
99
+ testBin ( '--bonjour' )
100
+ . then ( ( output ) => {
101
+ expect ( output . exitCode ) . toEqual ( 0 ) ;
102
+ expect (
103
+ normalizeStderr ( output . stderr , { ipv6 : true } )
104
+ ) . toMatchSnapshot ( ) ;
104
105
105
- done ( ) ;
106
- } )
107
- . catch ( done ) ;
108
- } ) ;
106
+ done ( ) ;
107
+ } )
108
+ . catch ( done ) ;
109
+ } ) ;
109
110
110
- it ( '--bonjour and --https' , ( done ) => {
111
- testBin ( '--bonjour --https' )
112
- . then ( ( output ) => {
113
- expect ( output . exitCode ) . toEqual ( 0 ) ;
114
- expect (
115
- normalizeStderr ( output . stderr , { ipv6 : true , https : true } )
116
- ) . toMatchSnapshot ( ) ;
111
+ it ( '--bonjour and --https' , ( done ) => {
112
+ testBin ( '--bonjour --https' )
113
+ . then ( ( output ) => {
114
+ expect ( output . exitCode ) . toEqual ( 0 ) ;
115
+ expect (
116
+ normalizeStderr ( output . stderr , { ipv6 : true , https : true } )
117
+ ) . toMatchSnapshot ( ) ;
117
118
118
- done ( ) ;
119
- } )
120
- . catch ( done ) ;
121
- } ) ;
119
+ done ( ) ;
120
+ } )
121
+ . catch ( done ) ;
122
+ } ) ;
122
123
123
- it ( '--no-bonjour' , ( done ) => {
124
- testBin ( '--no-bonjour' )
125
- . then ( ( output ) => {
126
- expect ( output . exitCode ) . toEqual ( 0 ) ;
127
- expect (
128
- normalizeStderr ( output . stderr , { ipv6 : true } )
129
- ) . toMatchSnapshot ( ) ;
124
+ it ( '--no-bonjour' , ( done ) => {
125
+ testBin ( '--no-bonjour' )
126
+ . then ( ( output ) => {
127
+ expect ( output . exitCode ) . toEqual ( 0 ) ;
128
+ expect (
129
+ normalizeStderr ( output . stderr , { ipv6 : true } )
130
+ ) . toMatchSnapshot ( ) ;
130
131
131
- done ( ) ;
132
- } )
133
- . catch ( done ) ;
132
+ done ( ) ;
133
+ } )
134
+ . catch ( done ) ;
135
+ } ) ;
134
136
} ) ;
135
137
136
138
describe ( 'client option' , ( ) => {
@@ -915,19 +917,11 @@ describe('CLI', () => {
915
917
} ) ;
916
918
} ) ;
917
919
918
- it ( 'should generate correct cli flags' , ( done ) => {
919
- const isMacOS = process . platform === 'darwin' ;
920
-
920
+ ( isMacOS ? it . skip : it ) ( 'should generate correct cli flags' , ( done ) => {
921
921
testBin ( '--help' )
922
922
. then ( ( output ) => {
923
- // TODO: find a fix, skip for MacOS
924
- if ( isMacOS ) {
925
- expect ( output . exitCode ) . toBe ( 0 ) ;
926
- done ( ) ;
927
- } else {
928
- expect ( stripAnsi ( output . stdout ) ) . toMatchSnapshot ( ) ;
929
- done ( ) ;
930
- }
923
+ expect ( stripAnsi ( output . stdout ) ) . toMatchSnapshot ( ) ;
924
+ done ( ) ;
931
925
} )
932
926
. catch ( done ) ;
933
927
} ) ;
@@ -937,76 +931,57 @@ describe('CLI', () => {
937
931
testBin ( '--static' )
938
932
. then ( ( output ) => {
939
933
expect ( output . exitCode ) . toEqual ( 0 ) ;
934
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
940
935
done ( ) ;
941
936
} )
942
937
. catch ( done ) ;
943
938
} ) ;
944
939
945
940
it ( '--static <value>' , ( done ) => {
946
- testBin (
947
- `--static ${ path . resolve (
948
- __dirname ,
949
- '../fixtures/static/webpack.config.js'
950
- ) } `
951
- )
941
+ testBin ( '--static new-static' )
952
942
. then ( ( output ) => {
953
943
expect ( output . exitCode ) . toEqual ( 0 ) ;
944
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
954
945
done ( ) ;
955
946
} )
956
947
. catch ( done ) ;
957
948
} ) ;
958
949
959
950
it ( '--static-reset' , ( done ) => {
960
- testBin (
961
- `--static-reset --static ${ path . resolve (
962
- __dirname ,
963
- '../fixtures/static/webpack.config.js'
964
- ) } `
965
- )
951
+ testBin ( '--static-reset --static new-static-after-reset' )
966
952
. then ( ( output ) => {
967
953
expect ( output . exitCode ) . toEqual ( 0 ) ;
954
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
968
955
done ( ) ;
969
956
} )
970
957
. catch ( done ) ;
971
958
} ) ;
972
959
973
960
it ( '--static-reset --static-directory <value>' , ( done ) => {
974
- testBin (
975
- `--static-reset --static-directory ${ path . resolve (
976
- __dirname ,
977
- '../fixtures/static/webpack.config.js'
978
- ) } `
979
- )
961
+ testBin ( '--static-reset --static-directory new-static-directory' )
980
962
. then ( ( output ) => {
981
963
expect ( output . exitCode ) . toEqual ( 0 ) ;
964
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
982
965
done ( ) ;
983
966
} )
984
967
. catch ( done ) ;
985
968
} ) ;
986
969
987
970
it ( '--static-directory' , ( done ) => {
988
- testBin (
989
- `--static-directory ${ path . resolve (
990
- __dirname ,
991
- '../fixtures/static/webpack.config.js'
992
- ) } `
993
- )
971
+ testBin ( '--static-directory static-dir' )
994
972
. then ( ( output ) => {
995
973
expect ( output . exitCode ) . toEqual ( 0 ) ;
974
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
996
975
done ( ) ;
997
976
} )
998
977
. catch ( done ) ;
999
978
} ) ;
1000
979
1001
980
it ( '--static --static-directory' , ( done ) => {
1002
- testBin (
1003
- `--static --static-directory ${ path . resolve (
1004
- __dirname ,
1005
- '../fixtures/static/webpack.config.js'
1006
- ) } `
1007
- )
981
+ testBin ( '--static --static-directory static-dir' )
1008
982
. then ( ( output ) => {
1009
983
expect ( output . exitCode ) . toEqual ( 0 ) ;
984
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1010
985
done ( ) ;
1011
986
} )
1012
987
. catch ( done ) ;
@@ -1016,6 +991,7 @@ describe('CLI', () => {
1016
991
testBin ( '--static-public-path /public' )
1017
992
. then ( ( output ) => {
1018
993
expect ( output . exitCode ) . toEqual ( 0 ) ;
994
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1019
995
done ( ) ;
1020
996
} )
1021
997
. catch ( done ) ;
@@ -1025,6 +1001,7 @@ describe('CLI', () => {
1025
1001
testBin ( '--static-public-path-reset --static-public-path /new-public' )
1026
1002
. then ( ( output ) => {
1027
1003
expect ( output . exitCode ) . toEqual ( 0 ) ;
1004
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1028
1005
done ( ) ;
1029
1006
} )
1030
1007
. catch ( done ) ;
@@ -1034,6 +1011,7 @@ describe('CLI', () => {
1034
1011
testBin ( '--static-serve-index' )
1035
1012
. then ( ( output ) => {
1036
1013
expect ( output . exitCode ) . toEqual ( 0 ) ;
1014
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1037
1015
done ( ) ;
1038
1016
} )
1039
1017
. catch ( done ) ;
@@ -1043,6 +1021,7 @@ describe('CLI', () => {
1043
1021
testBin ( '--no-static-serve-index' )
1044
1022
. then ( ( output ) => {
1045
1023
expect ( output . exitCode ) . toEqual ( 0 ) ;
1024
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1046
1025
done ( ) ;
1047
1026
} )
1048
1027
. catch ( done ) ;
@@ -1052,6 +1031,7 @@ describe('CLI', () => {
1052
1031
testBin ( '--static-watch' )
1053
1032
. then ( ( output ) => {
1054
1033
expect ( output . exitCode ) . toEqual ( 0 ) ;
1034
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1055
1035
done ( ) ;
1056
1036
} )
1057
1037
. catch ( done ) ;
@@ -1061,34 +1041,11 @@ describe('CLI', () => {
1061
1041
testBin ( '--static-watch' )
1062
1042
. then ( ( output ) => {
1063
1043
expect ( output . exitCode ) . toEqual ( 0 ) ;
1044
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1064
1045
done ( ) ;
1065
1046
} )
1066
1047
. catch ( done ) ;
1067
1048
} ) ;
1068
-
1069
- it ( 'should log static' , ( done ) => {
1070
- testBin (
1071
- '--no-color' ,
1072
- path . resolve ( __dirname , '../fixtures/static/webpack.config.js' )
1073
- )
1074
- . then ( ( output ) => {
1075
- expect ( output . exitCode ) . toEqual ( 0 ) ;
1076
- done ( ) ;
1077
- } )
1078
- . catch ( ( err ) => {
1079
- const staticDirectory = path . resolve (
1080
- __dirname ,
1081
- '../fixtures/static/static'
1082
- ) ;
1083
-
1084
- // for windows
1085
- expect ( err . stderr ) . toContain (
1086
- `Content not from webpack is served from '${ staticDirectory } ' directory`
1087
- ) ;
1088
- expect ( err . stdout ) . toContain ( 'main.js' ) ;
1089
- done ( ) ;
1090
- } ) ;
1091
- } ) ;
1092
1049
} ) ;
1093
1050
1094
1051
describe ( 'watchFiles option' , ( ) => {
@@ -1101,6 +1058,7 @@ describe('CLI', () => {
1101
1058
testBin ( `--watch-files ${ watchDirectory } ` )
1102
1059
. then ( ( output ) => {
1103
1060
expect ( output . exitCode ) . toEqual ( 0 ) ;
1061
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1104
1062
done ( ) ;
1105
1063
} )
1106
1064
. catch ( done ) ;
@@ -1115,6 +1073,7 @@ describe('CLI', () => {
1115
1073
testBin ( `--watch-files-reset --watch-files ${ watchDirectory } ` )
1116
1074
. then ( ( output ) => {
1117
1075
expect ( output . exitCode ) . toEqual ( 0 ) ;
1076
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1118
1077
done ( ) ;
1119
1078
} )
1120
1079
. catch ( done ) ;
@@ -1129,6 +1088,7 @@ describe('CLI', () => {
1129
1088
testBin ( `--watch-files-reset --watch-files-paths ${ watchDirectory } ` )
1130
1089
. then ( ( output ) => {
1131
1090
expect ( output . exitCode ) . toEqual ( 0 ) ;
1091
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1132
1092
done ( ) ;
1133
1093
} )
1134
1094
. catch ( done ) ;
@@ -1143,6 +1103,7 @@ describe('CLI', () => {
1143
1103
testBin ( `--watch-files-paths ${ watchDirectory } ` )
1144
1104
. then ( ( output ) => {
1145
1105
expect ( output . exitCode ) . toEqual ( 0 ) ;
1106
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1146
1107
done ( ) ;
1147
1108
} )
1148
1109
. catch ( done ) ;
@@ -1157,6 +1118,7 @@ describe('CLI', () => {
1157
1118
testBin ( `--watch-files-paths-reset --watch-files-paths ${ watchDirectory } ` )
1158
1119
. then ( ( output ) => {
1159
1120
expect ( output . exitCode ) . toEqual ( 0 ) ;
1121
+ expect ( normalizeStderr ( output . stderr ) ) . toMatchSnapshot ( 'stderr' ) ;
1160
1122
done ( ) ;
1161
1123
} )
1162
1124
. catch ( done ) ;
0 commit comments