@@ -80,6 +80,7 @@ describe('lib/browsers/electron', () => {
80
80
attachToTargetUrl : sinon . stub ( ) . resolves ( this . pageCriClient ) ,
81
81
currentlyAttachedTarget : this . pageCriClient ,
82
82
close : sinon . stub ( ) . resolves ( ) ,
83
+ getWebSocketDebuggerUrl : sinon . stub ( ) . returns ( 'ws://debugger' ) ,
83
84
}
84
85
85
86
sinon . stub ( BrowserCriClient , 'create' ) . resolves ( this . browserCriClient )
@@ -111,8 +112,11 @@ describe('lib/browsers/electron', () => {
111
112
} )
112
113
113
114
context ( '.open' , ( ) => {
114
- beforeEach ( function ( ) {
115
- return this . stubForOpen ( )
115
+ beforeEach ( async function ( ) {
116
+ // shortcut to set the browserCriClient singleton variable
117
+ await electron . _getAutomation ( { } , { onError : ( ) => { } } , { } )
118
+
119
+ await this . stubForOpen ( )
116
120
} )
117
121
118
122
it ( 'calls render with url, state, and options' , function ( ) {
@@ -152,7 +156,7 @@ describe('lib/browsers/electron', () => {
152
156
} )
153
157
} )
154
158
155
- it ( 'is noop when before:browser:launch yields null' , function ( ) {
159
+ it ( 'executeBeforeBrowserLaunch is noop when before:browser:launch yields null' , function ( ) {
156
160
plugins . has . returns ( true )
157
161
plugins . execute . resolves ( null )
158
162
@@ -207,6 +211,25 @@ describe('lib/browsers/electron', () => {
207
211
expect ( Windows . removeAllExtensions ) . to . be . calledTwice
208
212
} )
209
213
} )
214
+
215
+ it ( 'sends after:browser:launch with debugger url' , function ( ) {
216
+ plugins . has . returns ( true )
217
+ plugins . execute . resolves ( null )
218
+
219
+ return electron . open ( 'electron' , this . url , this . options , this . automation )
220
+ . then ( ( ) => {
221
+ expect ( plugins . execute ) . to . be . calledWith ( 'after:browser:launch' , 'electron' , {
222
+ webSocketDebuggerUrl : 'ws://debugger' ,
223
+ } )
224
+ } )
225
+ } )
226
+
227
+ it ( 'executeAfterBrowserLaunch is noop if after:browser:launch is not registered' , function ( ) {
228
+ return electron . open ( 'electron' , this . url , this . options , this . automation )
229
+ . then ( ( ) => {
230
+ expect ( plugins . execute ) . not . to . be . calledWith ( 'after:browser:launch' )
231
+ } )
232
+ } )
210
233
} )
211
234
212
235
context ( '.connectProtocolToBrowser' , ( ) => {
@@ -821,7 +844,10 @@ describe('lib/browsers/electron', () => {
821
844
expect ( electron . _launchChild ) . to . be . calledWith ( this . url , parentWindow , this . options . projectRoot , this . state , this . options , this . automation )
822
845
} )
823
846
824
- it ( 'adds pid of new BrowserWindow to allPids list' , function ( ) {
847
+ it ( 'adds pid of new BrowserWindow to allPids list' , async function ( ) {
848
+ // shortcut to set the browserCriClient singleton variable
849
+ await electron . _getAutomation ( { } , { onError : ( ) => { } } , { } )
850
+
825
851
const opts = electron . _defaultOptions ( this . options . projectRoot , this . state , this . options )
826
852
827
853
const NEW_WINDOW_PID = ELECTRON_PID * 2
0 commit comments