Skip to content

Commit 82e470c

Browse files
committed
docs(testingAndDebugging): update spectron examples
1 parent df66831 commit 82e470c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

docs/guide/testingAndDebugging.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ vue-cli-plugin-electron-builder exports a `testWithSpectron` function. This func
3535
```javascript
3636
// This example uses Jest, but any testing framework will work as well
3737

38+
const spectron = require('spectron')
3839
const { testWithSpectron } = require('vue-cli-plugin-electron-builder')
3940
jest.setTimeout(50000)
4041

4142
test('a window is created', async () => {
42-
const { stdout, url, stopServe, app } = await testWithSpectron()
43+
// Only v2.0+ require you to pass spectron as an arg
44+
const { stdout, url, stopServe, app } = await testWithSpectron(spectron)
4345
// stdout is the log of electron:serve
4446
console.log(`electron:serve returned: ${stdout}`)
4547
// url is the url for the dev server created with electron:serve
@@ -56,9 +58,13 @@ Complete examples are available for [jest](https://github.com/nklayman/vue-cli-p
5658
`testWithSpectron` takes a config argument. That config argument has properties as defined:
5759

5860
```javascript
61+
const spectron = require('spectron')
5962
const { testWithSpectron } = require('vue-cli-plugin-electron-builder')
6063

61-
testWithSpectron({
64+
testWithSpectron(
65+
// Import of spectron, only required for v2.0+
66+
spectron,
67+
{
6268
noSpectron: false // Disables launching of Spectron. Enable this if you want to launch spectron yourself.
6369
noStart: false // Do not start Spectron app or wait for it to load. You will have to call app.start() and app.client.waitUntilWindowLoaded() before running any tests.
6470
forceDev: false // Run dev server in development mode. By default it is run in production (serve --mode production).
@@ -67,6 +73,6 @@ testWithSpectron({
6773
})
6874
```
6975

70-
:::tip Note
71-
DevTools are not opened as `IS_TEST` env variable is set to true. If devtools are opened, Spectron throws an error. See [this issue](https://github.com/electron/spectron/issues/174) for more details.
76+
:::warning
77+
Make sure to update spectron along with electron. See the [spectron version map](https://github.com/electron-userland/spectron#version-map) to determine what version of spectron you should be using.
7278
:::

0 commit comments

Comments
 (0)