The YAML example below assumes you have stored your API key as a secret named MOMENTIC_API_KEY in your project settings.

This configuration also assumes that the command npm run start will start your app on localhost:3000. If you are testing against a persistent staging or production server, you can remove --wait-on and --start.

Finally, this configuration assumes that you have committed your Momentic tests and configuration files to your Git repository.

version: 2.1

jobs:
  momentic:
    docker:
      - image: cimg/node:18.16.1
    steps:
      - checkout
      - run:
          name: Run all tests locally
          command: npx momentic@latest run ./momentic --api-key ${MOMENTIC_API_KEY} --wait-on localhost:3000 --start 'npm run start'
      - run:
          name: Failure handler
          command: |
            echo "oh no! tests failed!"
          when: on_fail

workflows:
  ci:
    jobs:
      - momentic

Was this page helpful?