2
我试图用摩卡测试我的.js类(不是一个节点)。我面临一个问题,因为我不知道如何导入它,因为它不包含module.exports或其他任何东西。所以,我的.js就像用摩卡测试客户端js
var User = function() {
this.add = function() { ... }
this.update = function() { ... }
}
我想测试其功能之一测试
var User = require('path/to/user.js');
describe('User object', function() {
it('should add some stuff', function() {
var user = new User();
...
})
});
这(有或无“VAR用户=”)预见的给我“不确定是不是一个功能“。我错过了什么? 谢谢。
[我如何用Mocha测试'正常'(非节点特定)JavaScript函数?](http://stackoverflow.com/questions/10204021/how-do-i-test-normal-non -node-specific-javascript-functions-with-mocha) – mfreitas
谢谢@mfreitas就是这样 –