Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Last active July 27, 2018 08:32
Show Gist options
  • Save ThaddeusJiang/3e4fb7d788f143ef98f634dc9771973c to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/3e4fb7d788f143ef98f634dc9771973c to your computer and use it in GitHub Desktop.
Setting Codecov

使用 Jest 做单元测试

配置

1. 配置 package.json

  "test": "cross-env CI=1 react-scripts test --env=jsdom",
  "test:watch": "react-scripts test --env=jsdom",
  "test:coverage": "npm test -- --coverage",
  // 关键
  "test:ci": "npm run test:coverage --coverageDirectory=coverage --collectCoverage",

2. 配置 .travis.yml

language: node_js
node_js:
  - 8
  - 10
cache:
  directories:
    - node_modules
install:
# 不用在 local 安装, 其实也可以安装成 dev 依赖
# 暂时使用这个。 FIXME:
  - npm install -g codecov

script:
  - npm run build
  - npm run test:ci
  - codecov

Ref

https://github.com/ThaddeusJiang/react-mobile-wrapper/pull/1/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment