1
1
const createProject = require ( './createProject.helper.js' )
2
- const { readFile , writeFile } = require ( 'fs-extra' )
2
+ const { copyFile , writeFile } = require ( 'fs-extra' )
3
3
const { join } = require ( 'path' )
4
4
const execa = require ( 'execa' )
5
5
@@ -15,15 +15,14 @@ module.exports = async testRunner => {
15
15
await project . rm ( 'tests/unit/example.spec.js' )
16
16
17
17
// Copy electron test
18
- const testFile = (
19
- await readFile (
20
- `./generator/templates/tests-${ testRunner } /tests/unit/electron.spec.js` ,
21
- 'utf8'
22
- )
23
- )
24
- // Fix some unknown error
25
- . replace ( 'testWithSpectron()' , 'testWithSpectron({ mode: "production" })' )
26
- await writeFile ( join ( project . dir , 'tests/unit/electron.spec.js' ) , testFile )
18
+ await copyFile ( `./generator/templates/tests-${ testRunner } /tests/unit/electron.spec.js` , join ( project . dir , 'tests/unit/electron.spec.js' ) )
19
+
20
+ // If there is not a second test file, the `serve:electron --headless` process cannot be killed on Windows
21
+ // One of the weirdest bugs I've ever seen
22
+ // Without this, tests will fail on Windows
23
+ if ( testRunner === 'jest' ) {
24
+ await writeFile ( join ( project . dir , 'tests/unit/second.spec.js' ) , 'test("extra", () => {})' )
25
+ }
27
26
28
27
await execa (
29
28
require . resolve ( '@vue/cli-service/bin/vue-cli-service' ) ,
0 commit comments