1
编写将通过浏览器加载到浏览器中的模块。我试图使用dojo/node
插件来对模块进行单元测试,但在尝试加载单元测试时无法正常工作。我是否需要打包需要单元测试的模块(即,在加载之前对它们进行浏览),还是有解决方法?通过实习生单元测试浏览器CommonJS模块
规格:
define([
'intern!object',
'intern/chai!assert',
'require',
// common css selectors
'intern/dojo/node!app/selectors'
], function (
registerSuite,
assert,
require,
SEL
) {
registerSuite({
name: 'Selectors Unit test',
'it is an object': function() {
assert.ok(typeof SEL === 'object',
'Selectors is an object');
}
});
});
模块:在http://localhost/node_modules/intern/client.html?config=tests/intern
错误给通过浏览器
module.exports = {
FOO : { _SELF: '#someId }
};
跑步是Uncaught Error: Cannot find the Node.js require
是否在浏览器环境中的Dojo插件的工作?