Files
freeCodeCamp/docs/how-to-add-cypress-tests.md
T
Kolade Chris d614c4173f docs: update pnpm commands, fix typos and grammar (#49990
* fix: improving the docs

* fix: did some more typos and gramos fixes

* fix: fixed typographical and grammatical errors, capitalized headings, made adjustments to the directories to run pnpm run create-project.

* Implemented Shaun's suggested changes

* Removed duplicate lines from my end

* Fixed a few "open-source" and "open source" confusion
2023-04-10 15:15:26 +05:30

2.3 KiB

How to add Cypress tests

When making changes to JavaScript, CSS, or HTML which could change the functionality or layout of a page, it's important to add corresponding Cypress integration tests.

To learn how to write Cypress tests, or 'specs', please see Cypress' official documentation.

Where to Add a Test

  • Cypress tests are in the ./cypress directory.

  • Cypress tests for a curriculum module are in the corresponding curriculum directory, i.e. cypress/integration/learn/responsive-web-design/basic-css/index.js.

How to Run Tests

Note

If using GitPod, please see Cypress-GitPod Setup

1. Ensure that MongoDB and Client Applications are Running

2. Run the Cypress Tests

To run tests against production builds, replace dev with prd below.

  • To run all tests in the ./cypress directory:

    pnpm run cypress:dev:run
    
  • To run a single test:

    pnpm run cypress -- run --spec=cypress/<path_to_test_file>
    

    For example:

    pnpm run cypress -- run --spec=cypress/e2e/default/landing.ts
    
  • To create a development build, start the development server, and run all existing cypress end-to-end tests:

    pnpm run e2e:dev:run
    

Cypress-GitPod Setup

1. Ensure Development Environment is Running

If starting the GitPod environment did not automatically develop the environment:

pnpm run create:config
  • Seed the database
pnpm run seed
  • Develop the server and client
pnpm run develop

2. Install Cypress Build Tools

pnpm run cypress:install-build-tools
  • When prompted in the terminal, select your keyboard layout by language/area

Now, Cypress can be run