Dependencies: "@vue/cli-plugin-unit-jest": "^4.5.13", "@vue/test-utils": "^1.2.1", "vue-jest": "^3.0.7"
I am dealing with an application that utilizes an alias (referred to as "foo") defined in vue.config.js:
module.exports = {
chainWebpack: (config) => {
// Add project name as alias
config.resolve.alias.set('foo', __dirname);
},
};
This alias is used for both import statements and HTML tag src attributes...
In main.js:
...
import App from 'foo/src/components/core/App';
...
In ../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" />
I have tried using a moduleNameMapper in jest.config.js like this:
'^foo(.*)$': '<rootDir>$1',
However, this approach does not seem to work for aliases present in the src attribute of HTML tags. Is there a way for vue-jest to interpret these paths specified in attribute paths through configuration options or other methods?
Any suggestions would be highly valuable.