Problem splitting tests using Jest


This is our config to split tests:

  • &test
    name: Run Tests
    command: |
    TESTFILES=(circleci tests glob "./packages/main/src/**/__tests__/*.(test|spec).(js|ts|tsx)" | circleci tests split) echo "All test files:" circleci tests glob "./packages/main/src/**/__tests__/*.(test|spec).(js|ts|tsx)" | xargs -n 1 echo echo "This job test files:" circleci tests glob "./packages/main/src/**/__tests__/*.(test|spec).(js|ts|tsx)" | circleci tests split | xargs -n 1 echo echo "Running tests:" JEST_JUNIT_OUTPUT="./test-results/jest/results.xml" yarn jest --maxWorkers=4 --coverage --forceExit --ci {TESTFILES}
    bash <(curl -s -t $CODECOV_UPLOAD_TOKEN

<<: *defaults
parallelism: 2
- attach_workspace:
at: ~/app
- restore_cache: *restore-mongodb-binaries-cache
- run: *copy_env
- run: *test
- restore_cache: *save-mongodb-binaries-cache
- store_test_results:
path: ./test-results

Use use the following docker to test

- image: entria/node-ci:0.1.12
- image: circleci/redis:4.0.9

The time to run in 1, 2 or 4 is the same for us


To make it easier for readers to check your work, would you format your post using Markdown? You can apply code formatting using triple backticks, on their own line, at the start and end of each code/config/logs block.