Execute Nightwatch test on CircleCI

Greeting ! This is a quick guide and not meant to be comprehensive. Honestly , its too easy and should not take more than 2 min to explain it 🙂

1. Hook CircleCI with Repository

Assuming you have an E2E test suite on the GitHub repository. Login to circleCI.com (using GitHub credentials) and perform hook connection with that repository (project) as shown below.

  • Click ‘Setup Project’ as shown above
  • On the next page, click ‘Add Config’

    This will permit that circleCI has the required authority to read the Nightwatch’s GitHub activity. Next is to create a configuration file that contains E2E execution steps.

2. Add YAML configuration file

  • It needs to be stored in the project root within folder – .circleCI/config.yml
  • Below is the configuration.
version: 2
jobs:
  build:
    docker:
    - image: circleci/node:10.12.0-browsers
    working_directory: ~/nw-ci-medium
    steps:
    - checkout
    - run:
        name: Installing nightwatch & Web drivers
        command: ls && npm install
    - run:
        name: Run integration test
        command: npm test
    - store_artifacts:
        path: Result
    - store_test_results:
        path: Result
workflows:
  version: 2
  workflow:
    jobs:
    - build
  • E2E test is executed within a docker container and using circleci/node:10.12.0-browsers, which has all the required package to execute the scenario such as chromedriver, chrome browser, java, etc. You can find it over here – link.
  • That’s it! The setup is done :). Next time any code changes within the repository will trigger the E2E automation scenario. In my case, it can be executed using the ‘npm test‘ as mentioned in YAML. This script contains: node nightwatch.js Scenarios/completed_task.js
  • My GitHub repository for this article is https://github.com/rajeevbarde/tw_nightwatch
  • CircleCI pipeline at https://circleci.com/gh/rajeevbarde/tw_nightwatch

THE END

Leave a Reply

Your email address will not be published.