Effective Test Strategies for Deployed NodeJS Services using LaunchDarkly Feature Flags and Cypress. Part2: testing

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • cypress-crud-api-test

    crud testing a serverless application with Cypress api tests

  • This is part two of a multi-part series. In the previous post we setup the flags, now we will test them. Before diving into testing feature flags, we will setup Cypress and transfer over the final CRUD e2e spec from the repo cypress-crud-api-test. That repo was featured in the blog post CRUD API testing a deployed service with Cypress. Note that the said repo and this service used to be separated - that is a known anti-pattern - and now we are combining the two in a whole. The change will provide us with the ability to use the LaunchDarkly (LD) client instance to make flag value assertions. We would not have that capability if the test code was in a separate repo than the source code, unless the common code was moved to a package & was imported to the two repos. In the real world if we had to apply that as a solution, we would want to have valuable trade-offs.

  • pizza-api

  • The branch prior to this work can be checked out at before-cypress-setup, and the PR for cypress setup can be found here. If you are following along, a practical way to accomplish this section is to copy over the PR.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • cypress-ld-control

    Set LaunchDarkly feature flags from Cypress tests

  • My friend Gleb Bahmutov authored an excellent blog on testing LD with Cypress, there he revealed his new plugin cypress-ld-control. We used it in Effective Test Strategies for Front-end Applications using LaunchDarkly Feature Flags and Cypress. Part2: testing. The distinction here is using the plugin for a deployed service and the consequential test strategies.

  • react-hooks-in-action-with-cypress

    React Hooks in Action Book, with Cypress e2e & component tests

  • See other plugin file examples here and here.

  • github-action

    GitHub Action for running Cypress end-to-end & component tests

  • # .github/workflows/main.yml name: cypress-crud-api-test on: push: workflow_dispatch: # if this branch is pushed back to back, cancel the older branch's workflow concurrency: group: ${{ github.ref }} && ${{ github.workflow }} cancel-in-progress: true jobs: test: strategy: # uses 1 CI machine matrix: machines: [1] runs-on: ubuntu-20.04 steps: - name: Checkout 🛎 uses: actions/checkout@v2 # https://github.com/cypress-io/github-action - name: Run api tests 🧪 uses: cypress-io/github-action@v3.0.2 with: browser: chrome record: true group: crud api test env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} LAUNCH_DARKLY_PROJECT_KEY: ${{ secrets.LAUNCH_DARKLY_PROJECT_KEY }} LAUNCH_DARKLY_AUTH_TOKEN: ${{ secrets.LAUNCH_DARKLY_AUTH_TOKEN }} LAUNCHDARKLY_SDK_KEY: ${{ secrets.LAUNCHDARKLY_SDK_KEY }} #{{ # Here we are running the unit tests after the e2e # taking advantage of npm install in Cypress GHA. # Ideally we install first, and carry over the cache # to unit and e2e jobs. # Check this link for the better way: # https://github.com/muratkeremozcan/react-hooks-in-action-with-cypress/blob/main/.github/workflows/main.yml - name: run unit tests run: npm run test

  • cypress-skip-test

    Discontinued Simple commands to skip a test based on platform, browser or a url

  • We can take advantage of another one of Gleb's fantastic plugins cypress-skip-test. npm install -D @cypress/skip-test and Add the below line to cypress/support/index.js:

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts