@@ -17,6 +17,8 @@ describe('runOpen util', () => {
17
17
18
18
it ( 'on specify URL' , ( ) => {
19
19
return runOpen ( 'https://example.com' , { } , console ) . then ( ( ) => {
20
+ expect ( opn ) . toBeCalledWith ( 'https://example.com' , { wait : false } ) ;
21
+
20
22
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
21
23
Array [
22
24
"https://example.com",
@@ -34,6 +36,10 @@ describe('runOpen util', () => {
34
36
{ openPage : '/index.html' } ,
35
37
console
36
38
) . then ( ( ) => {
39
+ expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
40
+ wait : false ,
41
+ } ) ;
42
+
37
43
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
38
44
Array [
39
45
"https://example.com/index.html",
@@ -51,6 +57,10 @@ describe('runOpen util', () => {
51
57
{ openPage : [ '/index.html' ] } ,
52
58
console
53
59
) . then ( ( ) => {
60
+ expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
61
+ wait : false ,
62
+ } ) ;
63
+
54
64
expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
55
65
} ) ;
56
66
} ) ;
@@ -61,6 +71,13 @@ describe('runOpen util', () => {
61
71
{ openPage : [ '/index.html' , '/index2.html' ] } ,
62
72
console
63
73
) . then ( ( ) => {
74
+ expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
75
+ wait : false ,
76
+ } ) ;
77
+ expect ( opn ) . toBeCalledWith ( 'https://example.com/index2.html' , {
78
+ wait : false ,
79
+ } ) ;
80
+
64
81
expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
65
82
expect ( opn . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
66
83
} ) ;
@@ -72,6 +89,11 @@ describe('runOpen util', () => {
72
89
{ open : 'Google Chrome' } ,
73
90
console
74
91
) . then ( ( ) => {
92
+ expect ( opn ) . toBeCalledWith ( 'https://example.com' , {
93
+ app : 'Google Chrome' ,
94
+ wait : false ,
95
+ } ) ;
96
+
75
97
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
76
98
Array [
77
99
"https://example.com",
@@ -90,6 +112,11 @@ describe('runOpen util', () => {
90
112
{ open : 'Google Chrome' , openPage : '/index.html' } ,
91
113
console
92
114
) . then ( ( ) => {
115
+ expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
116
+ app : 'Google Chrome' ,
117
+ wait : false ,
118
+ } ) ;
119
+
93
120
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
94
121
Array [
95
122
"https://example.com/index.html",
@@ -108,6 +135,11 @@ describe('runOpen util', () => {
108
135
{ open : 'Google Chrome' , openPage : 'https://example2.com' } ,
109
136
console
110
137
) . then ( ( ) => {
138
+ expect ( opn ) . toBeCalledWith ( 'https://example2.com' , {
139
+ app : 'Google Chrome' ,
140
+ wait : false ,
141
+ } ) ;
142
+
111
143
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
112
144
Array [
113
145
"https://example2.com",
@@ -126,6 +158,10 @@ describe('runOpen util', () => {
126
158
{ open : 'Google Chrome' , openPage : 'http://example2.com' } ,
127
159
console
128
160
) . then ( ( ) => {
161
+ expect ( opn ) . toBeCalledWith ( 'http://example2.com' , {
162
+ app : 'Google Chrome' ,
163
+ wait : false ,
164
+ } ) ;
129
165
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
130
166
Array [
131
167
"http://example2.com",
@@ -148,6 +184,14 @@ describe('runOpen util', () => {
148
184
} ,
149
185
console
150
186
) . then ( ( ) => {
187
+ expect ( opn ) . toBeCalledWith ( 'https://example2.com' , {
188
+ app : 'Google Chrome' ,
189
+ wait : false ,
190
+ } ) ;
191
+ expect ( opn ) . toBeCalledWith ( 'https://example3.com' , {
192
+ app : 'Google Chrome' ,
193
+ wait : false ,
194
+ } ) ;
151
195
expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
152
196
expect ( opn . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
153
197
} ) ;
@@ -162,6 +206,15 @@ describe('runOpen util', () => {
162
206
} ,
163
207
console
164
208
) . then ( ( ) => {
209
+ expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
210
+ app : 'Google Chrome' ,
211
+ wait : false ,
212
+ } ) ;
213
+ expect ( opn ) . toBeCalledWith ( 'https://example2.com' , {
214
+ app : 'Google Chrome' ,
215
+ wait : false ,
216
+ } ) ;
217
+
165
218
expect ( opn . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
166
219
expect ( opn . mock . calls [ 1 ] ) . toMatchSnapshot ( ) ;
167
220
} ) ;
@@ -183,6 +236,8 @@ describe('runOpen util', () => {
183
236
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
184
237
`"Unable to open \\"https://example.com\\" in browser. If you are running in a headless environment, please do not use the --open flag"`
185
238
) ;
239
+ expect ( opn ) . toBeCalledWith ( 'https://example.com' , { wait : false } ) ;
240
+
186
241
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
187
242
Array [
188
243
"https://example.com",
@@ -203,6 +258,10 @@ describe('runOpen util', () => {
203
258
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
204
259
`"Unable to open \\"https://example.com/index.html\\" in browser. If you are running in a headless environment, please do not use the --open flag"`
205
260
) ;
261
+ expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
262
+ wait : false ,
263
+ } ) ;
264
+
206
265
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
207
266
Array [
208
267
"https://example.com/index.html",
@@ -223,6 +282,11 @@ describe('runOpen util', () => {
223
282
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
224
283
`"Unable to open \\"https://example.com\\" in browser: \\"Google Chrome\\". If you are running in a headless environment, please do not use the --open flag"`
225
284
) ;
285
+ expect ( opn ) . toBeCalledWith ( 'https://example.com' , {
286
+ app : 'Google Chrome' ,
287
+ wait : false ,
288
+ } ) ;
289
+
226
290
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
227
291
Array [
228
292
"https://example.com",
@@ -244,6 +308,11 @@ describe('runOpen util', () => {
244
308
expect ( logMock . warn . mock . calls [ 0 ] [ 0 ] ) . toMatchInlineSnapshot (
245
309
`"Unable to open \\"https://example.com/index.html\\" in browser: \\"Google Chrome\\". If you are running in a headless environment, please do not use the --open flag"`
246
310
) ;
311
+ expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
312
+ app : 'Google Chrome' ,
313
+ wait : false ,
314
+ } ) ;
315
+
247
316
expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
248
317
Array [
249
318
"https://example.com/index.html",
@@ -255,5 +324,32 @@ describe('runOpen util', () => {
255
324
` ) ;
256
325
} ) ;
257
326
} ) ;
327
+
328
+ it ( 'on specify URL with page in Google Chrome incognito mode and log error ' , ( ) => {
329
+ return runOpen (
330
+ 'https://example.com' ,
331
+ {
332
+ open : { app : [ 'Google Chrome' , '--incognito' ] } ,
333
+ openPage : '/index.html' ,
334
+ } ,
335
+ logMock
336
+ ) . then ( ( ) => {
337
+ expect ( opn ) . toBeCalledWith ( 'https://example.com/index.html' , {
338
+ app : [ 'Google Chrome' , '--incognito' ] ,
339
+ } ) ;
340
+
341
+ expect ( opn . mock . calls [ 0 ] ) . toMatchInlineSnapshot ( `
342
+ Array [
343
+ "https://example.com/index.html",
344
+ Object {
345
+ "app": Array [
346
+ "Google Chrome",
347
+ "--incognito",
348
+ ],
349
+ },
350
+ ]
351
+ ` ) ;
352
+ } ) ;
353
+ } ) ;
258
354
} ) ;
259
355
} ) ;
0 commit comments