File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ describe('Routes', () => {
21
21
22
22
describe ( 'without headers' , ( ) => {
23
23
beforeAll ( ( done ) => {
24
- server = helper . start ( config , { } , done ) ;
24
+ server = helper . startAwaitingCompilation ( config , { } , done ) ;
25
25
req = request ( server . app ) ;
26
26
} ) ;
27
27
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ const Server = require('../lib/Server');
6
6
let server ;
7
7
8
8
module . exports = {
9
- start ( config , options , done ) {
9
+ // start server, returning the full setup of the server
10
+ // (both the server and the compiler)
11
+ startFullSetup ( config , options , done ) {
10
12
// eslint-disable-next-line no-undefined
11
13
if ( options . quiet === undefined ) {
12
14
options . quiet = true ;
@@ -21,7 +23,28 @@ module.exports = {
21
23
done ( ) ;
22
24
} ) ;
23
25
24
- return server ;
26
+ return {
27
+ server,
28
+ compiler,
29
+ } ;
30
+ } ,
31
+ startAwaitingCompilation ( config , options , done ) {
32
+ let readyCount = 0 ;
33
+ const ready = ( ) => {
34
+ readyCount += 1 ;
35
+ if ( readyCount === 2 ) {
36
+ done ( ) ;
37
+ }
38
+ } ;
39
+
40
+ const fullSetup = this . startFullSetup ( config , options , ready ) ;
41
+ // wait for compilation, since dev server can start before this
42
+ // https://github.com/webpack/webpack-dev-server/issues/847
43
+ fullSetup . compiler . hooks . done . tap ( 'done' , ready ) ;
44
+ return fullSetup . server ;
45
+ } ,
46
+ start ( config , options , done ) {
47
+ return this . startFullSetup ( config , options , done ) . server ;
25
48
} ,
26
49
close ( done ) {
27
50
if ( server ) {
You can’t perform that action at this time.
0 commit comments