我正在尝试将 ci/cd 工作流与 github Actions 一起使用,
我使用 jest 进行单元测试并设置moduleNameMapper
如下:
"moduleNameMapper": {
"^src/(.*)$": "<rootDir>/src/$1",
"^components/(.*)$": "<rootDir>/src/components/$1"
}
我可以npm test
在本地成功运行,但是 github 操作总是出错:
Could not locate module src/components/tool-panel/Container.vue (mapped as /home/runner/work/its-me/its-me/src/components/tool-panel/Container.vue)
Please check:
"moduleNameMapper": {
"/^src\/(.*)$/": "/home/runner/work/its-me/its-me/src/$1"
},
"resolver": undefined
似乎<rootDir>
被替换为/home/runner/work/its-me/its-me
,并且src
此路径中没有文件夹:/home/runner/work/its-me/its-me
。
那么如何设置正确的根路径?
我不确定是否可以通过 ssh 连接到 github 操作服务器。
这是我的 github 仓库:是我
任何帮助,将不胜感激!!
我认为问题在于您Container.vue
使用大写引用文件,C
但实际文件全部为小写。如果您的本地文件系统不区分大小写,它可以正常执行。
https://github.com/jeoy/its-me/blob/master/test/unit/toolContainer.spec.js#L8
将此处的文件名更改为全部小写:
import Container from 'src/components/tool-panel/Container.vue';
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句