How do I configure test reporting with Cypress?

I’m using Cypress integration tests in a CircleCI environment. Currently my CircleCI configuration fails to store the test reports as artifacts and include a summary. The screenshots and videos are successfully stored. Below I’m including the config.yml and a screenshot of the CircleCI dashboard.

I’ve consulted these pages of the CircleCI documentation:

Any pointers would be appreciated. Thank you!

config.yml

version: 2
jobs:
  build:
    working_directory: ~/nodefront
    docker:
      - image: cypress/base:6
        environment:
          TERM: xterm
    parallelism: 1
    steps:
      - checkout
      - restore_cache:
          name: Restoring cached yarn dependencies
          key: v3-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
      - run:
          name: Installing dependencies with yarn
          command: |
            yarn install --frozen-lockfile
            yarn list
      - save_cache: 
          name: Caching yarn dependencies
          key: v3-deps-{{ checksum "package.json" }}
          paths:
            - ~/.cache
      - run: mkdir -p integration-tests/test-results/junit integration-tests/cypress/videos integration-tests/cypress/screenshots
      - run:
          name: Running E2E tests with JUnit reporter
          command: $(yarn bin)/cypress run --project ./integration-tests --reporter junit --record --key 77ffe06e-0fe2-4b33-a5ff-4dcdf9e31c91
          environment: 
            MOCHA_FILE: integration-tests/test-results/junit/test-results-[hash].xml
          when: always
      - store_test_results:
          path: integration-tests/test-results
      - store_artifacts:
          path: integration-tests/test-results
      - store_artifacts:
          path: integration-tests/cypress/videos
      - store_artifacts:
          path: integration-tests/cypress/screenshots

Screenshots

What happens if you set integration-tests/test-results to be stored as either test results or artefacts (and not both)? I don’t use these features but I wonder if adding it under both is causing an issue?

Well, since I posted there have been some significant structural changes to the repository… but I’ll post the relevant section of config.yml here. I can’t pinpoint what we did to fix it, but part of it was giving the Cypress subfolder (integration-tests) its own package.json, putting the relevant scripts in there, and proceeding with a cleaner .circleci/config.yml. We took out the mkdir statement and the environment object.

  test_cypress:
    working_directory: ~/theintercept
    docker:
      - image: cypress/base:6
        environment:
          TERM: xterm
    parallelism: 1
    steps:
      - checkout
      - restore_cache:
          name: Restoring cached yarn dependencies
          keys:
            - integration-tests-yarn-dependencies-{{ checksum "integration-tests/yarn.lock" }}
      - run:
          name: Installing dependencies with yarn
          command: |
            cd integration-tests
            yarn install --frozen-lockfile
            yarn list
      - save_cache:
          name: Caching yarn dependencies
          key: integration-tests-yarn-dependencies-{{ checksum "integration-tests/yarn.lock" }}
          paths:
            - ~/.cache/Cypress
            - ~/.cache/yarn
            - ~/theintercept/integration-tests/node_modules
      - run:
          name: Running E2E tests with JUnit reporter
          command: |
            cd integration-tests
            yarn test:record
      - store_test_results:
          path: integration-tests/test-results
      - store_artifacts:
          path: integration-tests/test-results
      - store_artifacts:
          path: integration-tests/test-artifacts
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.