依赖项: "@vue/cli-plugin-unit-jest": "^4.5.13", "@vue/test-utils": "^1.2.1", "vue-jest": "^3.0.7"
我有一个应用程序,在vue.config.js中设置了一个别名(比如说"foo"):
module.exports = {
chainWebpack: (config) => {
// 将项目名称设置为别名
config.resolve.alias.set('foo', __dirname);
},
};
对于导入语句和HTML标签的src属性...
在main.js中:
... import App from 'foo/src/components/core/App'; ...
在../src/core/App/index.vue中:
<script src="foo/src/components/core/App/script.js" /> <style module src="foo/src/components/core/App/style.css" /> <template src="foo/src/components/core/App/template.html" />
我知道我可以在jest.config.js中使用moduleNameMapper,类似于:
'^foo(.*)$': '
然而,这不会映射出现在HTML标签的src属性中的别名。有没有办法通过配置设置或其他方式让vue-jest解释这些属性路径呢?
非常感谢任何建议。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号