File tree 3 files changed +45
-1
lines changed
3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -662,7 +662,7 @@ class Server {
662
662
) ;
663
663
}
664
664
665
- if ( this . options . open ) {
665
+ if ( this . options . open || this . options . openPage ) {
666
666
runOpen ( localUrlForTerminal , this . options , this . logger ) ;
667
667
}
668
668
}
Original file line number Diff line number Diff line change @@ -42,6 +42,32 @@ describe('open option', () => {
42
42
server . listen ( port , 'localhost' ) ;
43
43
} ) ;
44
44
45
+ it ( 'should work with unspecified open option' , ( done ) => {
46
+ const compiler = webpack ( config ) ;
47
+ const server = new Server ( compiler , {
48
+ openPage : 'index.html' ,
49
+ port,
50
+ static : false ,
51
+ } ) ;
52
+
53
+ compiler . hooks . done . tap ( 'webpack-dev-server' , ( ) => {
54
+ server . close ( ( ) => {
55
+ expect ( open . mock . calls [ 1 ] ) . toMatchInlineSnapshot ( `
56
+ Array [
57
+ "http://localhost:8117/index.html",
58
+ Object {
59
+ "wait": false,
60
+ },
61
+ ]
62
+ ` ) ;
63
+ done ( ) ;
64
+ } ) ;
65
+ } ) ;
66
+
67
+ compiler . run ( ( ) => { } ) ;
68
+ server . listen ( port , 'localhost' ) ;
69
+ } ) ;
70
+
45
71
it ( 'should work with "0.0.0.0" host' , ( done ) => {
46
72
const compiler = webpack ( config ) ;
47
73
const server = new Server ( compiler , {
Original file line number Diff line number Diff line change @@ -119,6 +119,24 @@ describe('runOpen util', () => {
119
119
` ) ;
120
120
} ) ) ;
121
121
122
+ it ( 'on specify URL with openPage option only ' , ( ) =>
123
+ runOpen ( 'https://example.com' , { openPage : '/index.html' } , console ) . then (
124
+ ( ) => {
125
+ expect ( open ) . toBeCalledWith ( 'https://example.com/index.html' , {
126
+ wait : false ,
127
+ } ) ;
128
+
129
+ expect ( open . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
130
+ Array [
131
+ "https://example.com/index.html",
132
+ Object {
133
+ "wait": false,
134
+ },
135
+ ]
136
+ ` ) ;
137
+ }
138
+ ) ) ;
139
+
122
140
it ( 'on specify absolute https URL with page in Google Chrome ' , ( ) =>
123
141
runOpen (
124
142
'https://example.com' ,
You can’t perform that action at this time.
0 commit comments