我正在使用chai-as-promised + mocha来编写一些selenium-webdriver测试.由于webdriver广泛使用promises,我想如果我使用chai-as-promised进行那些类型的测试会更好.
问题是当测试失败时,mocha没有正确捕获错误,它只是失败而没有输出任何东西.
示例代码:
it 'tests log', (next) ->
log = @client.findElement(By.css("..."))
Q.all([
expect(log.getText()).to.eventually.equal("My Text")
expect(log.findElement(By.css(".image")).getAttribute('src'))
.to.eventually.equal("/test.png")
]).should.notify(next)
Run Code Online (Sandbox Code Playgroud)
根据记录的行为,当预期失败时,chai-as-promise应该将错误传递给mocha.对?
作为变种,
我也试过这些,但无济于事:
# same, no error on failure
it 'tests log', (next) ->
log = @client.findElement(By.css("..."))
Q.all([
expect(log.getText()).to.eventually.equal("My Text")
expect(log.findElement(By.css(".image")).getAttribute('src'))
.to.eventually.equal("/test.png")
]).should.notify(next)
Run Code Online (Sandbox Code Playgroud)
# same, no error shown on failure
it 'tests log', (next) ->
log = @client.findElement(By.css("..."))
expect(log.getText()).to.eventually.equal("My Text")
.then ->
expect(log.findElement(By.css(".image")).getAttribute('src'))
.to.eventually.equal("/test.png").should.notify(next)
Run Code Online (Sandbox Code Playgroud)
## DOES NOT EVEN …Run Code Online (Sandbox Code Playgroud) 希望这不会被当作两次问相同的问题...
因此,我正在一个Flash网站(在AS2中)工作,该网站具有外部索引swf,可使用来加载子swf文件loadMovie("subfoo1.swf", placeToShowSwf)。这些反过来加载一个xml文件,告诉它要加载什么内容。一切正常,但是我们想在索引swf中添加一个按钮,以打开一个子swf文件,其中一个或两个变量具有一个或两个不同的值。
不幸的是,只添加了一个说
loadMovie("foo1.swf", placeToShowSwf);
placeToShowSwf.openProject(x);
Run Code Online (Sandbox Code Playgroud)
不起作用,我认为是因为openProject(x)在未完全加载的文件上调用。我知道代码没有问题,因为我在其他地方创建了一个仅调用按钮,placeToShowSwf.openProject(x)没有任何问题。
我看到两个解决方案,我不确定该怎么做。
loadMovie(new foo1.swf(x), placeToShowSwf)或等效的话真是太好了。placeToShowSwf.openProject(x)。有人对这些解决方案有任何指导,或者有人以类似豌豆的大脑无法理解的其他方式获得了指导?
我正在尝试使用Electron构建应用程序.
我需要根据电子env和使用电子封装进行一些单元测试.
这样,我使用spectron来模拟我的应用程序.
在文档中,我写道我必须在'path'属性中放入我的可执行文件所在的路径.我现在没有可执行文件,我处于开发模式.
以下是我根据另一个问题尝试的内容:
beforeEach(() => {
app = new Application({
path: 'node_modules/.bin/electron'
});
app.start().then(res => console.log(res), err => console.log(err));
});
Run Code Online (Sandbox Code Playgroud)
提示中没有任何内容,并且以下测试失败告诉我无法在未定义的对象上获取getWindowCount(显然,应用程序未实例化):
it('should call currentWindow', (done) => {
app.client.getWindowCount().then((count) => {
expect(count).to.equals(1);
done();
});
});
Run Code Online (Sandbox Code Playgroud)
有谁知道我应该在这条道路上放置什么来让我的测试环境工作?
PS:我使用摩卡柴和sinon.
谢谢你的帮助