Skip to content

Commit dd60260

Browse files
committed
fix(tests): spectron-jest not exiting on windows
1 parent 166bc80 commit dd60260

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

__tests__/testWithSpectron.helper.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const createProject = require('./createProject.helper.js')
2-
const { readFile, writeFile } = require('fs-extra')
2+
const { copyFile, writeFile } = require('fs-extra')
33
const { join } = require('path')
44
const execa = require('execa')
55

@@ -15,15 +15,14 @@ module.exports = async testRunner => {
1515
await project.rm('tests/unit/example.spec.js')
1616

1717
// 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+
}
2726

2827
await execa(
2928
require.resolve('@vue/cli-service/bin/vue-cli-service'),

0 commit comments

Comments
 (0)