Skip to content

Commit f61d2b7

Browse files
committed
tests(testWithSpectron): run tests in parallel
1 parent 14efe97 commit f61d2b7

File tree

4 files changed

+40
-31
lines changed

4 files changed

+40
-31
lines changed

__tests__/testWithSpectron.helper.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const createProject = require('./createProject.helper.js')
2+
const { readFile, writeFile } = require('fs-extra')
3+
const { join } = require('path')
4+
5+
module.exports = async testRunner => {
6+
const plugins = {}
7+
plugins[`@vue/cli-plugin-unit-${testRunner}`] = {}
8+
const { project } = await createProject(
9+
`spectron-${testRunner}`,
10+
false,
11+
plugins
12+
)
13+
// Remove example test
14+
await project.rm('tests/unit/example.spec.js')
15+
16+
// Copy electron test
17+
const testFile = (await readFile(
18+
`./generator/templates/tests-${testRunner}/tests/unit/electron.spec.js`,
19+
'utf8'
20+
))
21+
// Fix some unknown error
22+
.replace('testWithSpectron()', 'testWithSpectron({ mode: "production" })')
23+
await writeFile(join(project.dir, 'tests/unit/electron.spec.js'), testFile)
24+
25+
await project.run('vue-cli-service test:unit')
26+
}

__tests__/testWithSpectron.spec.js

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
jest.setTimeout(100000)
2+
3+
const runTests = require('./testWithSpectron.helper.js')
4+
5+
test('testWithSpectron works with Jest', async () => {
6+
await runTests('jest')
7+
})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
jest.setTimeout(100000)
2+
3+
const runTests = require('./testWithSpectron.helper.js')
4+
5+
test('testWithSpectron works with Mocha', async () => {
6+
await runTests('mocha')
7+
})

0 commit comments

Comments
 (0)