在我的vue.js项目中,我在src/api/user.js
import { HTTP } from '@/services/http'
export const user = {
login (email, password) {
return HTTP.post('v1/login', { email: email, password: password })
}
}
我试图在我的规范中使用inject-loader加载此文件:
const actionsInjector = require('inject-loader!../../../../src/api/user')
它返回以下错误:
Module not found: Error: Can't resolve '../../../../src/api/user' in '/home/mateusz/projects/e_lessons_frontend/test/unit/specs/store/user'
我该如何解决?
更新:
添加一个额外的../
后,我遇到了新的错误:
Error: Some of the injections you passed in are invalid.
Valid injection targets for this module are:
- @/services/http
The following injections were passed in:
- @/api/user
The following injections are invalid:
- @/api/user
这是由我的测试中的这行代码引起的:
// create the module with our mocks
const actions = actionsInjector({
'@/api/user': {
login (email, password) {
return { token: 'dupa' }
}
}
})
有什么想法吗?