File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed
Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -662,7 +662,7 @@ class Server {
662662 ) ;
663663 }
664664
665- if ( this . options . open ) {
665+ if ( this . options . open || this . options . openPage ) {
666666 runOpen ( localUrlForTerminal , this . options , this . logger ) ;
667667 }
668668 }
Original file line number Diff line number Diff line change @@ -42,6 +42,32 @@ describe('open option', () => {
4242 server . listen ( port , 'localhost' ) ;
4343 } ) ;
4444
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+
4571 it ( 'should work with "0.0.0.0" host' , ( done ) => {
4672 const compiler = webpack ( config ) ;
4773 const server = new Server ( compiler , {
Original file line number Diff line number Diff line change @@ -119,6 +119,24 @@ describe('runOpen util', () => {
119119 ` ) ;
120120 } ) ) ;
121121
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+
122140 it ( 'on specify absolute https URL with page in Google Chrome ' , ( ) =>
123141 runOpen (
124142 'https://example.com' ,
You can’t perform that action at this time.
0 commit comments