javascript - TheIntern.IO 测试运行程序实习生客户端问题 "Attempt to require unloaded module superagent"

标签 javascript node.js dojo intern

我正在尝试使用 http://theintern.io 运行测试NODEJS 客户端,但是我收到以下错误:

~/WebstormProjects/life-tracker3$ node node_modules/.bin/intern-client config=tests/local.intern reporters=console
Error: **Attempt to require unloaded module superagent**
    at contextRequire (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/intern/node_modules/dojo/dojo.js:255:12)
    at req (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/intern/node_modules/dojo/dojo.js:30:10)
    at /home/bogdanbiv/WebstormProjects/life-tracker3/tests/api_tests/express.tests.js:5:18
    at Function.vm.runInThisContext (/home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/intern/node_modules/istanbul/lib/hook.js:163:16)
    at /home/bogdanbiv/WebstormProjects/life-tracker3/node_modules/intern/node_modules/dojo/dojo.js:760:8
    at fs.js:268:14
    at Object.oncomplete (fs.js:107:15)

使用相同的配置文件 local.intern.config,intern-runner 打开浏览器并正常运行所有测试(单元+功能)。当然,有些测试确实会失败,但这是可以预料的。完整的“实习生”配置可在 http://pastebin.com/c24QPxYE 获取。 .

最佳答案

堆栈跟踪表明您正在/home/bogdanbiv/WebstormProjects/life-tracker3/tests/api_tests/express.tests.js:5:18 调用 require('superagent'),但没有实际上将 superagent 模块指定为依赖项,因此无法加载。 Intern 测试中的 require 函数是 AMD 加载器的 require 函数,而不是 Node.js require 函数。请参阅testing non-AMD code有关如何加载非 AMD 依赖项的更多信息,请参阅文档。

关于javascript - TheIntern.IO 测试运行程序实习生客户端问题 "Attempt to require unloaded module superagent",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25233887/

相关文章:

node.js - Realm 与关系读取数据

dojo - 如何优化 Dojo 加载时间?

javascript - 动态遍历未知深度键的对象

javascript - 为 HTML5 <canvas> 实现魔杖?

javascript - 使用 Hapi.js 创建服务器

node.js - 需要使用 Electron JS 与现金抽屉等硬件设备进行交互

javascript - 如何为 Dojo 对话运行 onLoad 事件?

javascript - 为什么 dojo 1.7 不能显示对话框?

javascript - 巴别塔 : duplicate plugin/preset error detected

javascript - 无法使用 jQuery 正确打印 JSON 数组中的数据