我刚刚开始在此项目中添加测试,并决定添加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",
对我感到羞耻:这是一个对案例敏感的问题。
我也有同样的问题。在本地所有测试都通过,但是在CircleCi上,我发现没有发现错误。我发现本地我正在导入一个名为 Header
的组件(带有资本h(,但在git上,它被命名为 header
。