File tree Expand file tree Collapse file tree 5 files changed +59
-2
lines changed Expand file tree Collapse file tree 5 files changed +59
-2
lines changed Original file line number Diff line number Diff line change 1
1
const fs = require ( 'fs' )
2
2
3
3
module . exports = ( api , options = { } ) => {
4
+ if ( ! options . electronBuilder ) options . electronBuilder = { }
4
5
const usesTS = api . hasPlugin ( 'typescript' )
5
6
const hasBackground =
6
7
fs . existsSync ( api . resolve ( `./src/background.ts` ) ) ||
7
8
fs . existsSync ( api . resolve ( `./src/background.js` ) )
8
9
if ( ! hasBackground ) {
9
10
// If user does not have a background file so it should be created
10
- api . render ( './template' )
11
+ api . render ( './templates/base' )
12
+ }
13
+ // Add tests
14
+ if ( options . electronBuilder . addTests ) {
15
+ let testFramework
16
+ // TODO: support mocha
17
+ // if (api.hasPlugin('unit-mocha')) testFramework = 'mocha'
18
+ if ( api . hasPlugin ( 'unit-jest' ) ) testFramework = 'jest'
19
+ if ( testFramework ) api . render ( `./templates/tests-${ testFramework } ` )
11
20
}
12
21
api . onCreateComplete ( ( ) => {
13
22
// Update .gitignore if it exists
@@ -63,7 +72,7 @@ module.exports = (api, options = {}) => {
63
72
postinstallScript = 'electron-builder install-app-deps'
64
73
}
65
74
const devDependencies = { }
66
- if ( options . electronBuilder && options . electronBuilder . electronVersion ) {
75
+ if ( options . electronBuilder . electronVersion ) {
67
76
// Use provided electron version
68
77
devDependencies . electron = options . electronBuilder . electronVersion
69
78
}
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ const { testWithSpectron } = require ( 'vue-cli-plugin-electron-builder' )
2
+ jest . setTimeout ( 50000 )
3
+
4
+ test ( 'Window Loads Properly' , async ( ) => {
5
+ // Wait for dev server to start
6
+ const { app, stopServe } = await testWithSpectron ( )
7
+ const win = app . browserWindow
8
+ const client = app . client
9
+
10
+ // Window was created
11
+ expect ( await client . getWindowCount ( ) ) . toBe ( 1 )
12
+ // It is not minimized
13
+ expect ( await win . isMinimized ( ) ) . toBe ( false )
14
+ // Window is visible
15
+ expect ( await win . isVisible ( ) ) . toBe ( true )
16
+ // Size is correct
17
+ const { width, height } = await win . getBounds ( )
18
+ expect ( width ) . toBeGreaterThan ( 0 )
19
+ expect ( height ) . toBeGreaterThan ( 0 )
20
+ // App is loaded properly
21
+ expect (
22
+ / W e l c o m e t o Y o u r V u e \. j s ( \+ T y p e S c r i p t ) ? A p p / . test (
23
+ await client . getHTML ( '#app' )
24
+ )
25
+ ) . toBe ( true )
26
+
27
+ await stopServe ( )
28
+ } )
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ module.exports = {
15
15
testPathIgnorePatterns : [
16
16
'/node_modules/' ,
17
17
'/__tests__/projects/' ,
18
+ '/generator/templates' ,
18
19
'.*.helper.js'
19
20
]
20
21
}
Original file line number Diff line number Diff line change @@ -28,5 +28,24 @@ module.exports = [
28
28
return true
29
29
}
30
30
}
31
+ } ,
32
+ {
33
+ name : 'electronBuilder.addTests' ,
34
+ type : 'confirm' ,
35
+ message : 'Add tests with Spectron to your project?' ,
36
+ when : ( ) => {
37
+ try {
38
+ // Attempt to read package.json
39
+ const pkg = require ( path . join ( process . cwd ( ) , 'package.json' ) )
40
+ // Don't show if electron version is already set
41
+ return pkg . devDependencies [ '@vue/cli-plugin-unit-jest' ]
42
+ // TODO: add support for mocha
43
+ // ||
44
+ // pkg.devDependencies['@vue/cli-plugin-unit-mocha']
45
+ } catch ( e ) {
46
+ console . log ( 'Unable to read package.json' )
47
+ return false
48
+ }
49
+ }
31
50
}
32
51
]
You can’t perform that action at this time.
0 commit comments