File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 type SetupWorkerApi ,
77 MockedRequest ,
88} from 'msw' ;
9+ import { StartReturnType } from 'msw/lib/types/setupWorker/glossary' ;
910import PassthroughRegistry from './passthrough-registry' ;
1011import type { Server } from 'miragejs' ;
1112import type { HTTPVerb , RouteHandler , ServerConfig } from 'miragejs/server' ;
@@ -67,6 +68,10 @@ type RouteOptions = {
6768 timing ?: boolean | number ;
6869} ;
6970
71+ type SetupWorkerApiWithStartPromise = SetupWorkerApi & {
72+ _startPromise : StartReturnType ;
73+ } ;
74+
7075const defaultRouteOptions = {
7176 coalesce : false ,
7277 timing : undefined ,
@@ -127,7 +132,7 @@ export default class MswConfig {
127132
128133 timing ?: number ;
129134
130- msw ?: SetupWorkerApi ;
135+ msw ?: SetupWorkerApiWithStartPromise ;
131136
132137 mirageServer ?: MirageServer ;
133138
@@ -447,10 +452,10 @@ export default class MswConfig {
447452 }
448453
449454 start ( ) {
450- this . msw = setupWorker ( ...this . handlers ) ;
455+ this . msw = setupWorker ( ...this . handlers ) as SetupWorkerApiWithStartPromise ;
451456
452457 let logging = this . mirageConfig ?. logging || false ;
453- this . msw . start ( {
458+ this . msw . _startPromise = this . msw . start ( {
454459 quiet : ! logging ,
455460 onUnhandledRequest : ( req ) => {
456461 const verb = req . method . toUpperCase ( ) ;
You can’t perform that action at this time.
0 commit comments