CircleCI React Orbs makes it easy to run tests, linting and code coverage on CircleCI.
- Includes the following jobs:
install
,test
,eslint
,stylelint
andbuild
- Allows
test
,eslint
,stylelint
andbuild
to run in parallel install
job caches NPM dependenciestest
shows test summary in CircleCIeslint
shows test summary in CircleCIstylelint
stores generated reports in artifacts
- Currently only supports yarn (we'll add NPM support shortly)
- Current Orb assumes: Create React App, Jest, ESLint and Stylelint
- TypeScript not supported yet, but will be in the future
The smallest meaningful setup is to run tests on every PR. To do this, you need the following configuration.
version: 2.1
orbs:
react: thefrontside/react@0.1.0
workflows:
# push workflow will be triggered when a new pull request is created
push:
jobs:
- react/install
- react/test
requires:
- react/install
For eslint
to run successfully, you need an eslint
script to be present in your package.json.
You can add it by doing the following,
yarn add --dev eslint
- Add
eslintConfig
to package.json or create an.eslintrc
file. The minimum configuration is this:
{
...
"eslintConfig": {
"extends": "react-app"
}
...
}
- Add
eslint
script to package.json{ "scripts": { ... "eslint": "eslint ./", } }
- ⛴ it.
For stylelint
to run succesfully, you need an stylelint
script to be present in your package.json
You can add it by doing the following,
yarn add --dev stylelint stylelint-config-standard stylelint-junit-formatter
- Create a
.stylelintrc.js
file with the followingmodule.exports = { extends: 'stylelint-config-standard' };
- Add
stylelint
script to package.json{ "script": { "stylelint": "stylelint \"src/**/*.css\"" } }
- 🚢 it.
- All PR are welcome.
- Anything addressed in Limitation is SUPER welcome.
- Adding tests to
.circleci/config.yml
makes it easier to accept PRs
This project uses Orb testing workflow described in orb-tools-orb. When you create a PR with a change, it'll automatically run tests and verify the orb.
You can save yourself a bit of time by running the following before creating the PR,
circleci config pack src | circleci config validate
circleci config validate .circleci/config.yml