我正在使用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这样做的正确方法是什么?我还尝试停止Application实例并启动一个新实例,结果与此类似。
发布于 2017-05-09 21:51:59
这似乎是可行的
// 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发布于 2017-08-07 17:31:29
下面的snippsets工作,
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"配合使用
https://stackoverflow.com/questions/42597716
复制相似问题