1
- const create = require ( '@vue/cli-test-utils/createTestProject' )
2
- const { defaultPreset } = require ( '@vue/cli/lib/options' )
1
+ const create = require ( './createProject.helper.js' )
3
2
const path = require ( 'path' )
4
3
const fs = require ( 'fs-extra' )
5
4
const Application = require ( 'spectron' ) . Application
@@ -8,24 +7,11 @@ const portfinder = require('portfinder')
8
7
portfinder . basePort = 9515
9
8
const runTests = useTS =>
10
9
new Promise ( async resolve => {
11
- // Prevent modification of import
12
- let preset = { ...defaultPreset }
13
- let projectName = 'build'
14
- if ( useTS ) {
15
- // Install typescript plugin
16
- defaultPreset . plugins [ '@vue/cli-plugin-typescript' ] = { }
17
- // Use different project name
18
- projectName += '-ts'
19
- }
10
+ const { project, projectName } = await create ( 'build' , useTS )
11
+
20
12
const projectPath = p =>
21
13
path . join ( process . cwd ( ) , '__tests__/projects/' + projectName , p )
22
- // Install vcp-electron-builder
23
- defaultPreset . plugins [ 'vue-cli-plugin-electron-builder' ] = { }
24
- const project = await create (
25
- projectName ,
26
- preset ,
27
- path . join ( process . cwd ( ) , '/__tests__/projects' )
28
- )
14
+
29
15
const { stdout } = await project . run (
30
16
'vue-cli-service build:electron --x64 --win zip --linux zip'
31
17
)
@@ -74,12 +60,52 @@ const runTests = useTS =>
74
60
// Make sure there are no fatal errors
75
61
expect ( log . level ) . not . toBe ( 'SEVERE' )
76
62
} )
63
+ let appBaseUrl = logs
64
+ // Find BASE_URL log
65
+ . find ( v => v . message . indexOf ( 'process.env.BASE_URL=' ) !== - 1 )
66
+ // Get just the value
67
+ . message . split ( '=' ) [ 1 ]
68
+ // Remove any quotes
69
+ appBaseUrl = appBaseUrl . replace ( '"' , '' )
70
+ // Base url should be root of server
71
+ expect ( path . normalize ( appBaseUrl ) ) . toBe (
72
+ projectPath (
73
+ 'dist_electron/win-unpacked/resources/app.asar/dist_electron/bundled'
74
+ )
75
+ )
76
+ let appStatic = logs
77
+ // Find __static log
78
+ . find ( v => v . message . indexOf ( '__static=' ) !== - 1 )
79
+ // Get just the value
80
+ . message . split ( '=' ) [ 1 ]
81
+ // Remove any quotes
82
+ appStatic = appStatic . replace ( '"' , '' )
83
+ // __static should point to public folder
84
+ expect ( path . normalize ( appStatic ) ) . toBe (
85
+ projectPath (
86
+ 'dist_electron/win-unpacked/resources/app.asar/dist_electron/bundled'
87
+ )
88
+ )
77
89
} )
78
90
await client . getMainProcessLogs ( ) . then ( logs => {
79
91
logs . forEach ( log => {
80
92
// Make sure there are no fatal errors
81
93
expect ( log . level ) . not . toBe ( 'SEVERE' )
82
94
} )
95
+ let appStatic = logs
96
+ // Find __static log
97
+ . find ( m => m . indexOf ( '__static=' ) !== - 1 )
98
+ // Get just the value
99
+ . split ( '=' ) [ 1 ]
100
+ // Remove any quotes
101
+ appStatic = appStatic . replace ( '"' , '' )
102
+ appStatic = appStatic . replace ( '' , '' )
103
+ // __static should point to public folder
104
+ expect ( path . normalize ( appStatic ) ) . toBe (
105
+ projectPath (
106
+ 'dist_electron/win-unpacked/resources/app.asar/dist_electron/bundled'
107
+ )
108
+ )
83
109
} )
84
110
// Window was created
85
111
expect ( await client . getWindowCount ( ) ) . toBe ( 1 )
0 commit comments