Splitting tests by weight: "Unable to save test results"

Hi, I would like to split my jest tests but getting the following error:

# Uploading test results
Unable to save test results from /home/circleci/project/reports/junit
Error error accessing path "/home/circleci/project/reports/junit": stat /home/circleci/project/reports/junit: no such file or directory
Found no test results, skipping
# Uploading artifacts
Uploading /home/circleci/project/reports/junit to ./reports/junit/
  No artifact files found at /home/circleci/project/reports/junit
Total size uploaded: 0 B

So every time I run the test, it says:

Error reading historical timing data: file does not exist
Requested weighting by historical based timing, but they are not present. Falling back to weighting by name.

Here is my config:

    - run:
        name: Run Tests
        command: |
          TEST=$(circleci tests glob "src/**/*.spec.js" | circleci tests split --split-by=timings)
          yarn test:unit:ci $TEST
        environment:
          JEST_JUNIT_OUTPUT_DIR: ./reports/junit/
    - store_test_results:
        path: ./reports/junit/
    - store_artifacts:
        path: ./reports/junit/

Please note that yarn test:unit:ci already includes the --runInBand option, and the reporters are specified in jest.config.js as follows:

reporters: process.env['CI'] === '1' ? ['default', 'jest-junit'] : ['default']

jest-junit is also already installed as part of devDependencies in package.json

Could anyone spot what I did wrong please? Thanks.

Hi @dessskris ,

For test-splitting to work, fetching a previous test results is required.
Hence, we would need to make sure your job above saves the test reports (JUnit XML files) successfully.

From your shared output, it suggests there are no test reports generated under reports/junit/ folder.
As a first step, can you confirm if running your unit tests will generate your test reports?

If it does, the next step is to make sure you are specifying the folder path correctly then.

Thanks for your reply.

I believe it doesn’t save the test reports (see the output of the two steps below)

# Uploading test results
Unable to save test results from /home/circleci/project/reports/junit
Error error accessing path "/home/circleci/project/reports/junit": stat /home/circleci/project/reports/junit: no such file or directory
Found no test results, skipping
# Uploading artifacts
Uploading /home/circleci/project/reports/junit to ./reports/junit/
  No artifact files found at /home/circleci/project/reports/junit
Total size uploaded: 0 B

I don’t understand why it doesn’t work though. Even if I change the path to just /reports or if I add a mkdir step beforehand it still doesn’t work.

Hi @dessskris ,

Thanks for your update!

If this is a public project, would you be able to share a link to the project (on GitHub etc)?
I would like to inspect how or if the running of tests (i.e., the test script and setup) generates any test reports.

Else, you can definitely file a support ticket (free) with us, so we can follow up with you too!
https://support.circleci.com/hc/en-us/requests/new