Problem splitting tests using Jest


#1

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 https://codecov.io/bash) -t $CODECOV_UPLOAD_TOKEN

test:
<<: *defaults
parallelism: 2
steps:
- 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

docker:
- 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


#2

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.