【问题标题】:How to set correct root path when use Github Actions ci/cd?使用 Github Actions ci/cd 时如何设置正确的根路径?
【发布时间】:2020-01-19 06:53:45
【问题描述】:

我正在尝试将 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

似乎&lt;rootDir&gt; 被替换为/home/runner/work/its-me/its-me,并且此路径中没有文件夹src/home/runner/work/its-me/its-me

那么如何设置正确的根路径?

我不确定我是否可以 ssh 到 github 操作服务器。

这是我的 github 仓库:It's me

任何帮助将不胜感激!

【问题讨论】:

    标签: jestjs github-actions


    【解决方案1】:

    我认为问题在于您使用大写的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';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-08
      • 2019-12-29
      • 2022-10-19
      • 2020-07-01
      • 1970-01-01
      • 2021-05-30
      • 2022-09-23
      • 2020-01-10
      相关资源
      最近更新 更多