@@ -5,81 +5,79 @@ const portfinder = require('portfinder')
55const checkLogs = require ( './checkLogs.helper.js' )
66
77portfinder . basePort = 9515
8- const runTests = useTS =>
9- new Promise ( async resolve => {
10- const { project, projectName } = await create ( 'build' , useTS )
8+ const runTests = async ( useTS ) => {
9+ const { project, projectName } = await create ( 'build' , useTS )
1110
12- const isWin = process . platform === 'win32'
13- const projectPath = p =>
14- path . join ( process . cwd ( ) , '__tests__/projects/' + projectName , p )
11+ const isWin = process . platform === 'win32'
12+ const projectPath = ( p ) =>
13+ path . join ( process . cwd ( ) , '__tests__/projects/' + projectName , p )
1514
16- await project . run ( 'vue-cli-service electron:build --x64 --dir' )
17- // Ensure /dist is not modified
18- expect ( project . has ( 'dist' ) ) . toBe ( false )
19- // Ensure build successfully outputted files
20- expect ( project . has ( 'dist_electron/bundled/index.html' ) ) . toBe ( true )
21- expect ( project . has ( 'dist_electron/bundled/favicon.ico' ) ) . toBe ( true )
22- expect ( project . has ( 'dist_electron/bundled/js' ) ) . toBe ( true )
23- expect ( project . has ( 'dist_electron/bundled/css' ) ) . toBe ( true )
24- expect ( project . has ( 'dist_electron/bundled/background.js' ) ) . toBe ( true )
25- if ( isWin ) {
26- expect ( project . has ( `dist_electron/win-unpacked/${ projectName } .exe` ) ) . toBe (
27- true
28- )
29- } else {
30- expect ( project . has ( `dist_electron/linux-unpacked/${ projectName } ` ) ) . toBe (
31- true
32- )
33- }
34- // Ensure that setup files were not created
35- expect ( project . has ( `dist_electron/${ projectName } Setup 0.1.0.exe` ) ) . toBe (
36- false
15+ await project . run ( 'vue-cli-service electron:build --x64 --dir' )
16+ // Ensure /dist is not modified
17+ expect ( project . has ( 'dist' ) ) . toBe ( false )
18+ // Ensure build successfully outputted files
19+ expect ( project . has ( 'dist_electron/bundled/index.html' ) ) . toBe ( true )
20+ expect ( project . has ( 'dist_electron/bundled/favicon.ico' ) ) . toBe ( true )
21+ expect ( project . has ( 'dist_electron/bundled/js' ) ) . toBe ( true )
22+ expect ( project . has ( 'dist_electron/bundled/css' ) ) . toBe ( true )
23+ expect ( project . has ( 'dist_electron/bundled/background.js' ) ) . toBe ( true )
24+ if ( isWin ) {
25+ expect ( project . has ( `dist_electron/win-unpacked/${ projectName } .exe` ) ) . toBe (
26+ true
3727 )
38- expect (
39- project . has ( `dist_electron/${ projectName } -0.1.0-x86_64.AppImage` )
40- ) . toBe ( false )
41- expect ( project . has ( `dist_electron/${ projectName } _0.1.0_amd64` ) ) . toBe ( false )
42- // Launch app with spectron
43- const app = new Application ( {
44- path : `./__tests__/projects/${ projectName } /dist_electron/${
45- isWin ? 'win' : 'linux'
46- } -unpacked/${ projectName } ${ isWin ? '.exe' : '' } `,
47- // Make sure tests do not interfere with each other
48- port : await portfinder . getPortPromise ( ) ,
49- // Increase wait timeout for parallel testing
50- waitTimeout : 10000
51- } )
52- await app . start ( )
53- const win = app . browserWindow
54- const client = app . client
55- await client . waitUntilWindowLoaded ( )
28+ } else {
29+ expect ( project . has ( `dist_electron/linux-unpacked/${ projectName } ` ) ) . toBe (
30+ true
31+ )
32+ }
33+ // Ensure that setup files were not created
34+ expect ( project . has ( `dist_electron/${ projectName } Setup 0.1.0.exe` ) ) . toBe (
35+ false
36+ )
37+ expect (
38+ project . has ( `dist_electron/${ projectName } -0.1.0-x86_64.AppImage` )
39+ ) . toBe ( false )
40+ expect ( project . has ( `dist_electron/${ projectName } _0.1.0_amd64` ) ) . toBe ( false )
41+ // Launch app with spectron
42+ const app = new Application ( {
43+ path : `./__tests__/projects/${ projectName } /dist_electron/${
44+ isWin ? 'win' : 'linux'
45+ } -unpacked/${ projectName } ${ isWin ? '.exe' : '' } `,
46+ // Make sure tests do not interfere with each other
47+ port : await portfinder . getPortPromise ( ) ,
48+ // Increase wait timeout for parallel testing
49+ waitTimeout : 10000
50+ } )
51+ await app . start ( )
52+ const win = app . browserWindow
53+ const client = app . client
54+ await client . waitUntilWindowLoaded ( )
5655
57- // Check that proper info was logged
58- await checkLogs ( { client, projectName, projectPath, mode : 'build' } )
56+ // Check that proper info was logged
57+ await checkLogs ( { client, projectName, projectPath, mode : 'build' } )
5958
60- // Window was created
61- expect ( await client . getWindowCount ( ) ) . toBe ( 1 )
62- // It is not minimized
63- expect ( await win . isMinimized ( ) ) . toBe ( false )
64- // Dev tools is not open
65- expect ( await win . isDevToolsOpened ( ) ) . toBe ( false )
66- // Window is visible
67- expect ( await win . isVisible ( ) ) . toBe ( true )
68- // Size is correct
69- const { width, height } = await win . getBounds ( )
70- expect ( width ) . toBeGreaterThan ( 0 )
71- expect ( height ) . toBeGreaterThan ( 0 )
72- // Load was successful
73- expect ( await app . webContents . isLoading ( ) ) . toBe ( false )
74- // App is loaded properly
75- expect (
76- ( await client . getHTML ( '#app' ) ) . indexOf (
77- `Welcome to Your Vue.js ${ useTS ? '+ TypeScript ' : '' } App`
78- )
79- ) . not . toBe ( - 1 )
59+ // Window was created
60+ expect ( await client . getWindowCount ( ) ) . toBe ( 1 )
61+ // It is not minimized
62+ expect ( await win . isMinimized ( ) ) . toBe ( false )
63+ // Dev tools is not open
64+ expect ( await win . isDevToolsOpened ( ) ) . toBe ( false )
65+ // Window is visible
66+ expect ( await win . isVisible ( ) ) . toBe ( true )
67+ // Size is correct
68+ const { width, height } = await win . getBounds ( )
69+ expect ( width ) . toBeGreaterThan ( 0 )
70+ expect ( height ) . toBeGreaterThan ( 0 )
71+ // Load was successful
72+ expect ( await app . webContents . isLoading ( ) ) . toBe ( false )
73+ // App is loaded properly
74+ expect (
75+ ( await client . getHTML ( '#app' ) ) . indexOf (
76+ `Welcome to Your Vue.js ${ useTS ? '+ TypeScript ' : '' } App`
77+ )
78+ ) . not . toBe ( - 1 )
8079
81- await app . stop ( )
82- resolve ( )
83- } )
80+ await app . stop ( )
81+ }
8482
8583module . exports . runTests = runTests
0 commit comments