在 Intern 中加载 Leadfoot 模块会产生错误
Posted
技术标签:
【中文标题】在 Intern 中加载 Leadfoot 模块会产生错误【英文标题】:Loading Leadfoot modules in Intern produces an error 【发布时间】:2014-09-03 03:48:07 【问题描述】:Leadfoot 作为 Intern 框架 (./node_modules/intern/node_modules/leadfoot
) 的一部分安装。但是,当我尝试在文档中使用它时 (https://theintern.github.io/leadfoot/pollUntil.html):
define([
'intern!object',
'intern/chai!assert',
'require'
], function (registerSuite, assert, require)
var url = '../../index.html';
var Command = require('leadfoot/Command');
var pollUntil = require('leadfoot/helpers/pollUntil');
registerSuite(
name: 'Todo (functional)',
'submit form': function ()
return this.remote.get(require.toUrl(url))
.findById('new-todo').then(function (val) , function(err)
console.log(err);
).click();
);
我收到以下错误:
$ intern-runner config=tests/example_intern
Listening on 0.0.0.0:9000
Starting tunnel...
Error: Attempt to require unloaded module leadfoot/Command
at contextRequire <node_modules/intern/node_modules/dojo/dojo.js:255:12>
at module.require.result <node_modules/intern/node_modules/dojo/dojo.js:284:13>
at </home/bogdanbiv/WebstormProjects/life-tracker3/dojo-example/tests/functional/Todo.js:9:16>
at execModule <node_modules/intern/node_modules/dojo/dojo.js:515:54>
at <node_modules/intern/node_modules/dojo/dojo.js:504:12>
at Array.map <native>
at execModule <node_modules/intern/node_modules/dojo/dojo.js:499:17>
at <node_modules/intern/node_modules/dojo/dojo.js:582:7>
at guardCheckComplete <node_modules/intern/node_modules/dojo/dojo.js:566:4>
at checkComplete <node_modules/intern/node_modules/dojo/dojo.js:574:27>
有人能解释一下如何在功能测试中正确使用 Leadfoot 吗?
插入建议的更改:
$ intern-runner config=dojo-example/tests/intern
Listening on 0.0.0.0:9000
Starting tunnel...
Error: Failed to load module leadfoot/helpers/pollUntil from /home/bogdanbiv/WebstormProjects/life-tracker3/leadfoot/helpers/pollUntil.js (parent: dojo-example/tests/functional/Todo)
at <node_modules/intern/node_modules/dojo/dojo.js:757:12>
at <fs.js:207:20>
在 Object.oncomplete
【问题讨论】:
【参考方案1】:尝试将 Leadfoot 模块 ID 放在 define
数组中,而不是 requiring
它们中。
define([
'intern!object',
'intern/chai!assert',
'require',
'intern/dojo/node!leadfoot/Command',
'intern/dojo/node!leadfoot/helpers/pollUntil'
], function (registerSuite, assert, require, Command, pollUntil)
【讨论】:
以上是关于在 Intern 中加载 Leadfoot 模块会产生错误的主要内容,如果未能解决你的问题,请参考以下文章