一起使用
我正在使用Spectron对我的电子应用程序运行集成测试。除了试图测试应用程序设置之间是否在应用程序重新启动之间持续正确存在,一切都很好。
在运行测试时,我的应用程序以每个测试的新临时userData
目录开始,以确保测试隔离。这意味着在单个测试中需要进行持续测试,并且要实现这一目标,我必须在测试中重新启动该应用程序。有一个app.restart
方法,所以必须对此进行支持吗?
我正在使用以下Spectron测试代码:
// save some settings here
await app.restart();
await app.client.waitUntilWindowLoaded()
// do some more checking to ensure the app is fully loaded
// check the settings here
但是,我遇到以下错误:
Error: waitUntilWindowLoaded Promise was rejected with the following reason:
Error: A session id is required for this command but wasn't found in the response payload
做到这一点的正确方法是什么?我还尝试过停止应用程序实例并启动具有相似结果的新应用程序。
这似乎有效
// save some settings here
await app.stop();
app = new Application({ ... });
await app.start();
await app.client.waitUntilWindowLoaded();
// do some more checking to ensure the app is fully loaded
// check the settings here
swippsets有效,
import test from 'ava'
import util from '../util'
test(async t => {
// This runs after each test and other test hooks, even if they failed
let app = util.createApp()
app = await util.waitForLoad(app, t)
await app.restart()
await app.client.waitUntilWindowLoaded()
// app = await util.waitForLoad(app, t)
})
与"spectron": "^3.5.0"