Reputation: 321
I am confusing something, or Jest should disable watch mode when running in a CI environment?
I am using github actions and the CI
environment variable is set to true
My package.json
has the entry test
"scripts": {
"test": "firebase emulators:exec --only firestore --project sample 'jest --runInBand --watch'"
}
Notice the --watch
, this make the Jest watch for new tests.
Here is my GitHub action file
name: Jest
on: [push, pull_request]
defaults:
run:
working-directory: functions
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: npm ci
- run: npm test
Because of that, my tests on Actions takes forever, until timeout.
I am missing something? Should Jest ignore the --watch
flag when running on CI mode?
Upvotes: 1
Views: 1530
Reputation: 89
I was wondering what happens if you use file watchers with CI. When using the default NPM test provided by react, there are no issues (they probably check for the CI env variable themselves). If I use jest --watchAll
.
The test keeps running. You can simply use different commands. I don't know of an elegant way to have if CI jest else jest --watchAll
in a single terminal command.
Upvotes: 1
Reputation: 2706
IF you're using jest via CRA (create-react-app) and running via some integration pipeline, then these pipelines typically set CI=true in the environment, in turn making CRA supply different configuration to jest.
So yes, you're likely confused (as am I) since CRA changes things.
And more confusion worth being aware of: https://github.com/facebook/create-react-app/issues/9345
Upvotes: 0