Skip to content

Michael-Robson/CypressTest

Repository files navigation

Cypress Test

Repository to renew and act as a portfolio of Cypress knowledge with examples running against the test app https://the-internet.herokuapp.com/

How The Project Works

This project uses yarn to handle dependencies required and scripts needed to run the tests along with other useful scripts we might want to use for linting.

Scripts and dependencies can be found in package.json

How The Cypress Tests Works

The Cypress framework uses the page object modal to make maintaining tests as easy as possible. The pages are stored in cypress\pages

Tests are stored in cypress\e2e

A HTML test report is generated after each run in cypress\reports\testReports

Custom commands that don't relate to a page object are added to cypress\support\commands.js

Global configuration, along with the before hooks is set in cypress\support\e2e.js

Reporter configraution and the base URL is set in cypress.config.js

Scripts We Can Run

yarn cypress:open - Opens the Cypress IDE
yarn lint - Runs eslint check on all Cypress files
yarn prettier:check - Reports on any formatting issues
yarn format - Fixes any formatting issues
yarn lint:fix - Fixes any linting issues
yarn beforePR - Runs both lint and format fix jobs
yarn allTestsChrome - Runs all the tests in headless chrome

Dev Dependencies Used

Linting

Linting is the process of performing static analysis on source code to flag patterns that might cause errors or other problems. As an application progresses through the various stages of development, code quality becomes critical.

In this project we are linting with the Cypress recommended ruleset and also running Prettier to make sure all code is formated to the same standard.

Using husky and lint-staged I've created a pre-commit job in .husky\pre-commit which runs the lint-staged job found in package.json

 "lint-staged": {
    "*.{js,jsx,ts,tsx}": "yarn lint:fix",
   "*.{js,jsx,ts,tsx,scss,css,json,md}": "yarn format"
  },

This means whenever a git commit occures we are running the two lint tasks found in package.json that format all the code using eslint and then format all the code with prettier, if any issues can't be automatically fixed you will receive an error message and the commit won't be pushed.

Notes and further reading

TODO: Add notes comment code!! JS or TS?! stick to JS for now cypress-xpath deprecated https://www.reddit.com/r/QualityAssurance/comments/162wt3i/are_there_any_sites_i_can_use_to_write_automated/

About

Repository to renew Cypress knowledge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published