How can we call the `cy:test-flight` given in package.json from `.cirlceci/config.yml` file

Viewed 43

For my cypress tests in my Circleci CI/CD pipeline, how can I call the command cy:test-flight given under scripts section in Package.json file from .cirlceci/config.yml. Also I would like to set following parameters record true and parallel set to 3. Could someone please advise on how to achieve this using .cirlceci/config.yml

Package.json

"scripts": {
    "cy:run": "cypress run",
    "get-token-flight": "node get-token.js && mv tokenData.json cypress/fixtures && mv cookies.json cypress/fixtures",
    "cy:open:flight": "npm run get-token-flight && cypress open",
    "cy:test-flight": "set CYPRESS_RETRIES=2 && npm run get-token-flight && cypress run --record --key <key-here> cypress --env configFile=flight-app --browser chrome"
  }

.cirlceci/config.yml

version: 2.1
orbs:
  cypress: cypress-io/cypress@1
workflows:
  build:
    jobs:
      - cypress/install
      - cypress/run
1 Answers

Here's an example of my circle.yml:

version: 2.1
jobs:
  test:
    docker:
    - image: cypress/base:10
    steps:
    - checkout
    - restore_cache:
        keys:
        - cache-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
    - run:
        name: Yarn install
        command: yarn install --frozen-lockfile
    - save_cache:
        key: cache-{{ arch }}-{{ .Branch }}-{{ checksum "package.json" }}
        paths:
        - ~/.cache
    - run:
        command: yarn lint
    - run:
        command: yarn test
    - run:
        command: yarn test-e2e
    - run:
        command: yarn run semantic-release
workflows:
  build:
    jobs:
    - test
  version: 2

So you can replace yarn test-e2e with npm run cy:test-flight for example

Also, here's a bunch of examples that utilize the cypress orb https://github.com/cypress-io/circleci-orb/blob/master/docs/examples.md#simple

Related