【问题标题】:Circle CI: Cannot find module ‘../../Themes’ from ‘RoundButton.js’. Working OK locallyCircle CI:无法从“RoundButton.js”中找到模块“../../Themes”。在本地工作正常
【发布时间】:2018-02-25 12:15:07
【问题描述】:

我刚开始在这个项目中添加测试,并决定添加 Circle CI。 到目前为止,它运行良好,包括测试。但是当我在 CircleCI 中运行它时,它失败了。

circleci.yml

version: 2
jobs:
  build:
    working_directory: ~/project
    docker:
      - image: circleci/node:8
    steps:
      - checkout
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          - v1-dependencies-
      - run: yarn install
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}
      - run: yarn test

测试输出:

#!/bin/bash -eo pipefail
yarn test
yarn run v1.3.2
$ jest --coverage
 FAIL  __tests__/Components/Shared/RoundButton.js
  ● Test suite failed to run

    Cannot find module '../../Themes' from 'RoundButton.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:191:17)
      at Object.<anonymous> (src/Components/Shared/RoundButton.js:12:13)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        2.514s
Ran all test suites.
----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |  Unknown |  Unknown |  Unknown |  Unknown |                   |
----------|----------|----------|----------|----------|-------------------|
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1

路径:

./__tests__/Components/Shared/RoundButton.js
./src/Components/Shared/RoundButton.js
./src/Themes

版本:

"babel-jest": "^22.2.2",
"jest": "^22.4.2",

【问题讨论】:

  • 在本地同目录运行会出现这种情况吗?
  • 我尝试过 SSH,它也发生了。我在本地克隆了一个新文件夹,但它没有发生(但我在快照上有缩进错误,我正在检查为什么 atm)@NickMcCurdy

标签: react-native jestjs circleci


【解决方案1】:

真丢脸:这是一个区分大小写的问题。

【讨论】:

    【解决方案2】:

    我有同样的问题。在本地,所有测试都通过了,但是在 circleci 上,我得到了 module not found 错误。我发现我在本地导入了一个名为 Header(大写 H)的组件,但在 git 上,它被命名为 header

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-18
      • 1970-01-01
      • 2020-06-16
      • 1970-01-01
      • 2021-07-09
      • 2023-01-26
      • 2019-01-21
      • 2021-11-06
      相关资源
      最近更新 更多