我尝试在VueJS
和Quasar框架
中使用Jest
。 我编写了一个简单的测试:
import { GetUserDictionaryDataComponent, Component } from '@/pages/configurations/components/';
describe('GetUserDictionaryDataComponent', () => {
it('should get correct type', () => {
const component = new GetUserDictionaryDataComponent(undefined);
expect(component.getComponentType()).toBe(Component.LEAF);
});
});
但是它不能正常工作。当我尝试运行我的测试时,我会收到错误提示:
Test suite failed to run
Configuration error:
Could not locate module @/pages/configurations/components/ mapped as:
/home/user/git/my_project/client/src/pages/configurations/components/.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/^@\/(.*)$/": "/home/user/git/my_project/client/src/$1"
},
"resolver": null
}
> 1 | import { GetUserDictionaryDataComponent, Component } from '@/pages/configurations/components/';
| ^
2 |
3 | describe('GetUserDictionaryDataComponent', () => {
4 | it('should get correct type', () => {
at createNoMappedModuleFoundError (node_modules/@jest/core/node_modules/jest-resolve/build/index.js:472:17)
at Object.<anonymous> (src/tests/pages/configurations/components/GetUserDictionaryDataComponent.spec.js:1:1)
但是,我不明白为什么会出现这个错误。我检查了路径/home/user/git/my_project/client/src/pages/configurations/components/
是正确的,我的类就在那里。