【发布时间】:2014-03-17 18:20:27
【问题描述】:
我在功能测试中使用任何 dojo 模块时遇到问题,我不断看到 window 未定义错误或 document 未定义。
我目前正在尝试像这样使用dijit/registry(目前只导入它的模块)..
define([
'intern!object',
'intern/chai!assert',
'require',
'dijit/registry'
], function (registerSuite, assert, require, registry) {
registerSuite({
name: 'login',
'load and login': function () {
return this.remote.get(require.toUrl('http://application.co.uk/'))
.elementById('input1')
.click()
.type("username")
.end()
.elementById('input2')
.click()
.type("password")
.end()
.elementById('rememberMe')
.click()
.end()
.elementByName('Login.Submit')
.click()
.end()
.wait(5000)
.title()
.then(function (title) {
assert.strictEqual(title, 'Application title');
});
}
});
});
...并且从节点收到以下错误...
$ ./libs/intern/bin/intern-runner.js config=test/intern
Defaulting to "runner" reporter
Listening on 0.0.0.0:9000
c:/.../libs/dojo/_base/unload.js:6
var win = window;
^
ReferenceError: window is not defined
at c:/.../libs/dojo/_base/unload.js:6:11
at execModule (c:\...\libs\intern\node_modules\dojo\dojo.js:512:54)
at c:\...\libs\intern\node_modules\dojo\dojo.js:501:12
at Array.map (native)
at execModule (c:\...\libs\intern\node_modules\dojo\dojo.js:496:17)
at c:\...\libs\intern\node_modules\dojo\dojo.js:501:12
at Array.map (native)
at execModule (c:\...\libs\intern\node_modules\dojo\dojo.js:496:17)
at c:\...\libs\intern\node_modules\dojo\dojo.js:501:12
at Array.map (native)
我读过之前的问题about using dojo/text! in a similar way,这似乎表明实习生的 geezer 版本可能可以处理这个问题?
没有注册表模块,测试运行良好。
更新
好吧,根据 C Snover 的响应,您不能在 webdriver execute() 方法之外利用像 dijit/registry 这样的任何东西,因为代码需要在 Web 浏览器的上下文中,而不是在功能测试中。
【问题讨论】:
标签: javascript dojo functional-testing intern