@@ -123,6 +123,63 @@ describe("API", () => {
123123 await server . stop ( ) ;
124124 } ) ;
125125
126+ it ( `should work and allow to rerun dev server multiple times` , async ( ) => {
127+ const compiler = webpack ( config ) ;
128+ const server = new Server ( { port } , compiler ) ;
129+
130+ await server . start ( ) ;
131+
132+ const { page : firstPage , browser } = await runBrowser ( ) ;
133+
134+ const firstPageErrors = [ ] ;
135+ const firstConsoleMessages = [ ] ;
136+
137+ firstPage
138+ . on ( "console" , ( message ) => {
139+ firstConsoleMessages . push ( message ) ;
140+ } )
141+ . on ( "pageerror" , ( error ) => {
142+ firstPageErrors . push ( error ) ;
143+ } ) ;
144+
145+ await firstPage . goto ( `http://127.0.0.1:${ port } /main` , {
146+ waitUntil : "networkidle0" ,
147+ } ) ;
148+
149+ expect (
150+ firstConsoleMessages . map ( ( message ) => message . text ( ) )
151+ ) . toMatchSnapshot ( "console messages" ) ;
152+ expect ( firstPageErrors ) . toMatchSnapshot ( "page errors" ) ;
153+
154+ await server . stop ( ) ;
155+ await server . start ( ) ;
156+
157+ const secondPage = await browser . newPage ( ) ;
158+
159+ const secondPageErrors = [ ] ;
160+ const secondConsoleMessages = [ ] ;
161+
162+ secondPage
163+ . on ( "console" , ( message ) => {
164+ secondConsoleMessages . push ( message ) ;
165+ } )
166+ . on ( "pageerror" , ( error ) => {
167+ secondPageErrors . push ( error ) ;
168+ } ) ;
169+
170+ await secondPage . goto ( `http://127.0.0.1:${ port } /main` , {
171+ waitUntil : "networkidle0" ,
172+ } ) ;
173+
174+ expect (
175+ secondConsoleMessages . map ( ( message ) => message . text ( ) )
176+ ) . toMatchSnapshot ( "console messages" ) ;
177+ expect ( secondPageErrors ) . toMatchSnapshot ( "page errors" ) ;
178+
179+ await browser . close ( ) ;
180+ await server . stop ( ) ;
181+ } ) ;
182+
126183 it ( "should work with deprecated API ('listen' and `close` methods)" , async ( ) => {
127184 const compiler = webpack ( config ) ;
128185 const devServerOptions = { port } ;
0 commit comments