Percy not running in CircleCI orbs (w/ Cypress)

582 Views Asked by At

I'm trying to get Percy.io to take snapshots of a simple test written in Cypress, building in CircleCI. However, the 'builds' are showing up as failed in the Percy dashboard despite the test/build passing in CircleCI. In the Cypress test runner it is showing 'Percy not running' where my snapshots are placed.

I've followed the tutorials on the Percy and Cypress sites. I can get Percy to work locally, by running percy exec -- cypress run but the CircleCI config doesn't run Cypress via the command cypress run, it runs it via the cypress orb.

It seems like the two orbs, Cypress and Percy, doesn't know the other exists.

Here's my CircleCI config file:

version: 2.1
orbs:
  node: circleci/[email protected]
  cypress: cypress-io/[email protected]
  slack: circleci/[email protected]
  percy: percy/[email protected]
  

workflows:
  version: 2
  commit-workflow:
    jobs:
      - cypress/run:
          name: Smoke Tests
          record: true
          store_artifacts: true  
          spec: cypress/integration/E2E/*
          post-steps:
            - store_test_results:
                path: test-results
            - slack/notify:
                channel: general
                event: fail
                template: basic_fail_1
                mentions: '@Jac'
            - slack/notify:
                channel: general
                event: pass
                template: basic_success_1
                mentions: '@Jac'   
      - percy/finalize_all:
            requires:
              - Smoke Tests

The Run Cypress Tests step doesn't make any mention of Percy, so I'm assuming it simply isn't running - that despite using the Percy orb, there's some sort of config I'm missing?

1

There are 1 best solutions below

0
On

Apologies, I keep finding answers to my questions after posting to Stack Overflow! I obviously don't know the properties of cypress/run well enough. But essentially, there's a custom command-prefix property that can be added for the purpose of amending the command used to run cypress. In fact, Percy is the example used in the Cypress docs.

Config now looks like:

version: 2.1
orbs:
  node: circleci/[email protected]
  cypress: cypress-io/[email protected]
  slack: circleci/[email protected]
  percy: percy/[email protected]
  

workflows:
  version: 2
  commit-workflow:
    jobs:
      - cypress/run:
          name: Smoke Tests
          record: true
          store_artifacts: true  
          spec: cypress/integration/E2E/*
          command-prefix: npx percy exec -- 
          post-steps:
            - store_test_results:
                path: test-results
            - slack/notify:
                channel: general
                event: fail
                template: basic_fail_1
                mentions: '@Jac'
            - slack/notify:
                channel: general
                event: pass
                template: basic_success_1
                mentions: '@Jac'   
      - percy/finalize_all:
            requires:
              - Smoke Tests