【发布时间】:2015-03-04 11:44:17
【问题描述】:
我正在使用 jasmine 固定装置,并且我想使用其中包含 iframe 的 HTML 编写测试。
问题是测试在我的 iframe 加载之前执行。
图书馆本身有解决方案吗?
还是我必须实现自己的机制让它等待?
代码如下:
夹具:
<iframe id="test-iframe1" class="test-iframe1" src="data/tests/pages/iframe1.html" style="width: 400px; height: 600px;" frameborder="20"></iframe>
测试:
describe("iframe -", function() {
beforeEach(function() {
var f = jasmine.getFixtures();
f.fixturesPath = 'base/tests/pages/';
f.load('iframe-main.htm');
});
it('iframe exists', function() {
// HERE - the iframe has not yet loaded
expect($('#test-iframe1').length).toBe(1);
});
});
【问题讨论】:
标签: javascript iframe jasmine fixtures