0

我正在尝试将 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 仓库:是我

任何帮助,将不胜感激!!

4

1 回答 1

2

我认为问题在于您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';
于 2019-09-18T12:23:23.790 回答