@@ -82,11 +82,11 @@ const runCommand = async (command, options = {}, args = {}, rawArgs = []) => {
82
82
}
83
83
// #endregion
84
84
85
- describe ( 'build: electron' , ( ) => {
85
+ describe ( 'electron:build ' , ( ) => {
86
86
process . env . NODE_ENV = 'production'
87
87
88
88
test ( 'typescript is disabled when set in options' , async ( ) => {
89
- await runCommand ( 'build: electron' , {
89
+ await runCommand ( 'electron:build ' , {
90
90
pluginOptions : {
91
91
electronBuilder : {
92
92
disableMainProcessTypescript : true
@@ -106,7 +106,7 @@ describe('build:electron', () => {
106
106
} )
107
107
108
108
test ( 'custom background file is used if provided' , async ( ) => {
109
- await runCommand ( 'build: electron' , {
109
+ await runCommand ( 'electron:build ' , {
110
110
pluginOptions : {
111
111
electronBuilder : {
112
112
mainProcessFile : 'customBackground.js'
@@ -122,7 +122,7 @@ describe('build:electron', () => {
122
122
} )
123
123
124
124
test ( 'custom output dir is used if set in vue.config.js' , async ( ) => {
125
- await runCommand ( 'build: electron' , {
125
+ await runCommand ( 'electron:build ' , {
126
126
pluginOptions : {
127
127
electronBuilder : {
128
128
outputDir : 'output'
@@ -142,7 +142,7 @@ describe('build:electron', () => {
142
142
} )
143
143
144
144
test ( 'custom output dir is used if dest arg is passed' , async ( ) => {
145
- await runCommand ( 'build: electron' , { } , { dest : 'output' } )
145
+ await runCommand ( 'electron:build ' , { } , { dest : 'output' } )
146
146
147
147
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
148
148
// Main config output is correct
@@ -156,7 +156,7 @@ describe('build:electron', () => {
156
156
} )
157
157
158
158
test ( 'Custom main process webpack config is used if provided' , async ( ) => {
159
- await runCommand ( 'build: electron' , {
159
+ await runCommand ( 'electron:build ' , {
160
160
pluginOptions : {
161
161
electronBuilder : {
162
162
chainWebpackMainProcess : config => {
@@ -172,12 +172,12 @@ describe('build:electron', () => {
172
172
} )
173
173
174
174
test ( 'process.env.IS_ELECTRON is set to true' , async ( ) => {
175
- await runCommand ( 'build: electron' )
175
+ await runCommand ( 'electron:build ' )
176
176
expect ( process . env . IS_ELECTRON ) . toBe ( 'true' )
177
177
} )
178
178
179
179
test ( 'Custom Electron Builder config is used if provided' , async ( ) => {
180
- await runCommand ( 'build: electron' , {
180
+ await runCommand ( 'electron:build ' , {
181
181
pluginOptions : {
182
182
electronBuilder : {
183
183
builderOptions : {
@@ -193,7 +193,7 @@ describe('build:electron', () => {
193
193
test ( 'Fonts folder is copied to css if it exists' , async ( ) => {
194
194
// Mock existence of fonts folder
195
195
fs . existsSync . mockReturnValueOnce ( true )
196
- await runCommand ( 'build: electron' )
196
+ await runCommand ( 'electron:build ' )
197
197
// css/fonts folder was created
198
198
expect ( fs . ensureDirSync . mock . calls [ 1 ] [ 0 ] ) . toBe (
199
199
'projectPath/dist_electron/bundled/css/fonts'
@@ -208,7 +208,7 @@ describe('build:electron', () => {
208
208
} )
209
209
210
210
test ( '.js and .ts are merged into file extensions' , async ( ) => {
211
- await runCommand ( 'build: electron' )
211
+ await runCommand ( 'electron:build ' )
212
212
213
213
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
214
214
// Both .js and .ts are resolved
@@ -221,61 +221,61 @@ describe('build:electron', () => {
221
221
[ '--skipBundle' ] ,
222
222
[ '--dest' , 'output' ]
223
223
] ) ( '%s argument is removed from electron-builder args' , async ( ...args ) => {
224
- await runCommand ( 'build: electron' , { } , { } , [ '--keep1' , ...args , '--keep2' ] )
224
+ await runCommand ( 'electron:build ' , { } , { } , [ '--keep1' , ...args , '--keep2' ] )
225
225
// Custom args should have been removed, and other args kept
226
226
expect ( mockYargsParse ) . toBeCalledWith ( [ '--keep1' , '--keep2' ] )
227
227
mockYargsParse . mockClear ( )
228
228
229
- await runCommand ( 'build: electron' , { } , { } , [ ...args , '--keep2' ] )
229
+ await runCommand ( 'electron:build ' , { } , { } , [ ...args , '--keep2' ] )
230
230
// Custom args should have been removed, and other args kept
231
231
expect ( mockYargsParse ) . toBeCalledWith ( [ '--keep2' ] )
232
232
mockYargsParse . mockClear ( )
233
233
234
- await runCommand ( 'build: electron' , { } , { } , [ '--keep1' , ...args ] )
234
+ await runCommand ( 'electron:build ' , { } , { } , [ '--keep1' , ...args ] )
235
235
// Custom args should have been removed, and other args kept
236
236
expect ( mockYargsParse ) . toBeCalledWith ( [ '--keep1' ] )
237
237
mockYargsParse . mockClear ( )
238
238
239
- await runCommand ( 'build: electron' , { } , { } , args )
239
+ await runCommand ( 'electron:build ' , { } , { } , args )
240
240
// Custom args should have been removed
241
241
expect ( mockYargsParse ) . toBeCalledWith ( [ ] )
242
242
mockYargsParse . mockClear ( )
243
243
244
- await runCommand ( 'build: electron' , { } , { } , [ '--keep1' , '--keep2' ] )
244
+ await runCommand ( 'electron:build ' , { } , { } , [ '--keep1' , '--keep2' ] )
245
245
// Nothing should be removed
246
246
expect ( mockYargsParse ) . toBeCalledWith ( [ '--keep1' , '--keep2' ] )
247
247
} )
248
248
249
249
test ( 'Modern mode is enabled by default' , async ( ) => {
250
- await runCommand ( 'build: electron' )
250
+ await runCommand ( 'electron:build ' )
251
251
expect ( serviceRun . mock . calls [ 0 ] [ 1 ] . modern ) . toBe ( true )
252
252
} )
253
253
254
254
test ( 'Modern mode is disabled if --legacy arg is passed' , async ( ) => {
255
- await runCommand ( 'build: electron' , { } , { legacy : true } )
255
+ await runCommand ( 'electron:build ' , { } , { legacy : true } )
256
256
expect ( serviceRun . mock . calls [ 0 ] [ 1 ] . modern ) . toBe ( false )
257
257
} )
258
258
259
259
test ( 'App is not bundled if --skipBundle arg is passed' , async ( ) => {
260
- await runCommand ( 'build: electron' , { } , { skipBundle : true } )
260
+ await runCommand ( 'electron:build ' , { } , { skipBundle : true } )
261
261
expect ( serviceRun ) . not . toBeCalled ( )
262
262
expect ( webpack ) . not . toBeCalled ( )
263
263
} )
264
264
265
265
test ( 'Env vars prefixed with VUE_APP_ are available in main process config' , async ( ) => {
266
266
process . env . VUE_APP_TEST = 'expected'
267
- await runCommand ( 'serve: electron' )
267
+ await runCommand ( 'electron:serve ' )
268
268
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
269
269
// Env var is set correctly
270
270
expect ( mainConfig . plugins [ 1 ] . defaultValues . VUE_APP_TEST ) . toBe ( 'expected' )
271
271
} )
272
272
} )
273
273
274
- describe ( 'serve: electron' , ( ) => {
274
+ describe ( 'electron:serve ' , ( ) => {
275
275
process . env . NODE_ENV = 'development'
276
276
277
277
test ( 'typescript is disabled when set in options' , async ( ) => {
278
- await runCommand ( 'serve: electron' , {
278
+ await runCommand ( 'electron:serve ' , {
279
279
pluginOptions : {
280
280
electronBuilder : {
281
281
disableMainProcessTypescript : true
@@ -295,7 +295,7 @@ describe('serve:electron', () => {
295
295
} )
296
296
297
297
test ( 'custom background file is used if provided' , async ( ) => {
298
- await runCommand ( 'serve: electron' , {
298
+ await runCommand ( 'electron:serve ' , {
299
299
pluginOptions : {
300
300
electronBuilder : {
301
301
mainProcessFile : 'customBackground.js'
@@ -311,7 +311,7 @@ describe('serve:electron', () => {
311
311
} )
312
312
313
313
test ( 'custom output dir is used if set in vue.config.js' , async ( ) => {
314
- await runCommand ( 'serve: electron' , {
314
+ await runCommand ( 'electron:serve ' , {
315
315
pluginOptions : {
316
316
electronBuilder : {
317
317
outputDir : 'output'
@@ -325,7 +325,7 @@ describe('serve:electron', () => {
325
325
} )
326
326
327
327
test ( 'Custom main process webpack config is used if provided' , async ( ) => {
328
- await runCommand ( 'serve: electron' , {
328
+ await runCommand ( 'electron:serve ' , {
329
329
pluginOptions : {
330
330
electronBuilder : {
331
331
chainWebpackMainProcess : config => {
@@ -341,12 +341,12 @@ describe('serve:electron', () => {
341
341
} )
342
342
343
343
test ( 'process.env.IS_ELECTRON is set to true' , async ( ) => {
344
- await runCommand ( 'serve: electron' )
344
+ await runCommand ( 'electron:serve ' )
345
345
expect ( process . env . IS_ELECTRON ) . toBe ( 'true' )
346
346
} )
347
347
348
348
test ( 'If --debug argument is passed, electron is not launched, main process is not minified, and source maps are enabled' , async ( ) => {
349
- await runCommand ( 'serve: electron' , { } , { debug : true } )
349
+ await runCommand ( 'electron:serve ' , { } , { debug : true } )
350
350
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
351
351
352
352
// UglifyJS plugin does not exist
@@ -362,7 +362,7 @@ describe('serve:electron', () => {
362
362
} )
363
363
364
364
test ( '.js and .ts are merged into file extensions' , async ( ) => {
365
- await runCommand ( 'serve: electron' )
365
+ await runCommand ( 'electron:serve ' )
366
366
367
367
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
368
368
// Both .js and .ts are resolved
@@ -377,7 +377,7 @@ describe('serve:electron', () => {
377
377
// Set callback to be called later
378
378
watchCb = cb
379
379
} )
380
- await runCommand ( 'serve: electron' , {
380
+ await runCommand ( 'electron:serve ' , {
381
381
pluginOptions : {
382
382
electronBuilder : {
383
383
// Make sure it watches proper background file
@@ -416,7 +416,7 @@ describe('serve:electron', () => {
416
416
// Set callback to be called later
417
417
watchCb [ file ] = cb
418
418
} )
419
- await runCommand ( 'serve: electron' , {
419
+ await runCommand ( 'electron:serve ' , {
420
420
pluginOptions : {
421
421
electronBuilder : {
422
422
// Make sure background file is watch as well
@@ -463,7 +463,7 @@ describe('serve:electron', () => {
463
463
} )
464
464
465
465
test ( 'Junk output is stripped from electron child process' , async ( ) => {
466
- await runCommand ( 'serve: electron' )
466
+ await runCommand ( 'electron:serve ' )
467
467
468
468
// Junk is removed
469
469
expect ( mockExeca . stderr . pipe ) . toBeCalledWith ( 'removeJunk' )
@@ -474,7 +474,7 @@ describe('serve:electron', () => {
474
474
} )
475
475
476
476
test ( 'Junk output is not stripped from electron child process if removeElectronJunk is set to false' , async ( ) => {
477
- await runCommand ( 'serve: electron' , {
477
+ await runCommand ( 'electron:serve ' , {
478
478
pluginOptions : { electronBuilder : { removeElectronJunk : false } }
479
479
} )
480
480
@@ -487,7 +487,7 @@ describe('serve:electron', () => {
487
487
} )
488
488
489
489
test ( 'package.json is copied' , async ( ) => {
490
- await runCommand ( 'serve: electron' , {
490
+ await runCommand ( 'electron:serve ' , {
491
491
pluginOptions : { electronBuilder : { outputDir : 'outputDir' } }
492
492
} )
493
493
@@ -526,7 +526,7 @@ describe('Custom webpack chain', () => {
526
526
527
527
test ( 'Env vars prefixed with VUE_APP_ are available in main process config' , async ( ) => {
528
528
process . env . VUE_APP_TEST = 'expected'
529
- await runCommand ( 'serve: electron' )
529
+ await runCommand ( 'electron:serve ' )
530
530
const mainConfig = webpack . mock . calls [ 0 ] [ 0 ]
531
531
// Env var is set correctly
532
532
expect ( mainConfig . plugins [ 1 ] . defaultValues . VUE_APP_TEST ) . toBe ( 'expected' )
@@ -551,7 +551,7 @@ describe('testWithSpectron', async () => {
551
551
}
552
552
} )
553
553
const testPromise = testWithSpectron ( spectronOptions )
554
- // Mock console.log from serve: electron
554
+ // Mock console.log from electron:serve
555
555
if ( launchOptions . customLog ) await sendData ( launchOptions . customLog )
556
556
await sendData ( `$outputDir=${ launchOptions . outputDir || 'dist_electron' } ` )
557
557
await sendData (
0 commit comments