使用 Github Actions ci/cd 时如何设置正确的根路径?
How to set correct root path when use Github Actions ci/cd?
我正在尝试将 ci/cd 工作流程与 github 操作一起使用,
我使用 jest 进行单元测试并设置 moduleNameMapper
如下所示:
"moduleNameMapper": {
"^src/(.*)$": "<rootDir>/src/",
"^components/(.*)$": "<rootDir>/src/components/"
}
我可以 运行 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/"
},
"resolver": undefined
似乎 <rootDir>
被替换为 /home/runner/work/its-me/its-me
,并且此路径中没有文件夹 src
:/home/runner/work/its-me/its-me
.
那么如何设置正确的根路径?
我不确定我是否可以通过 ssh 连接到 github 操作服务器。
这是我的 github 存储库:It's me
如有任何帮助,我们将不胜感激!!
我认为问题在于您使用大写 C
引用文件 Container.vue
,但实际文件全是小写。如果您的本地文件系统不区分大小写,它可能会执行得很好。
https://github.com/jeoy/its-me/blob/master/test/unit/toolContainer.spec.js#L8
将此处的文件名全部改为小写:
import Container from 'src/components/tool-panel/Container.vue';
我正在尝试将 ci/cd 工作流程与 github 操作一起使用,
我使用 jest 进行单元测试并设置 moduleNameMapper
如下所示:
"moduleNameMapper": {
"^src/(.*)$": "<rootDir>/src/",
"^components/(.*)$": "<rootDir>/src/components/"
}
我可以 运行 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/"
},
"resolver": undefined
似乎 <rootDir>
被替换为 /home/runner/work/its-me/its-me
,并且此路径中没有文件夹 src
:/home/runner/work/its-me/its-me
.
那么如何设置正确的根路径?
我不确定我是否可以通过 ssh 连接到 github 操作服务器。
这是我的 github 存储库:It's me
如有任何帮助,我们将不胜感激!!
我认为问题在于您使用大写 C
引用文件 Container.vue
,但实际文件全是小写。如果您的本地文件系统不区分大小写,它可能会执行得很好。
https://github.com/jeoy/its-me/blob/master/test/unit/toolContainer.spec.js#L8
将此处的文件名全部改为小写:
import Container from 'src/components/tool-panel/Container.vue';