尝试使用Jest测试角度服务并得到此错误:
[$injector:nomod] Module 'superag' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Run Code Online (Sandbox Code Playgroud)
如何模拟我的模块'superag'并使其可用mathService?
我是否必须在app.js每次测试时使用模块声明导入文件?
Ps.:我也试过beforeEach(module('superag'))没有成功
的package.json
"jest": {
"collectCoverageFrom": [
"**/*.{js}",
"!**/node_modules/**"
]
},
"devDependencies": {
"angular-mocks": "^1.6.9",
"jest-cli": "^23.0.0-alpha.0"
},
"dependencies": {
"angular": "^1.6.9"
}
}
Run Code Online (Sandbox Code Playgroud)
math.service.js
function MathService(){
var addTwoNumbers = function(x, y){
return x + y;
};
return {
addTwoNumbers
}; …Run Code Online (Sandbox Code Playgroud)