This project uses a Cypress folder structure to automate end-to-end testing for the Unity Grant Manager application. The Cypress testing framework executes automated tests to ensure the quality and reliability of the web application using continuous integration.
cypress/: Cypress configuration and test files.cypress.config.ts: Cypress configuration in TypeScript.cypress.pipeline.env.json: CI/CD environment overrides.package.json,package-lock.json: Project dependencies and metadata.tsconfig.json: TypeScript configuration.
See the README for setup and usage instructions.
To get started with this Cypress project, follow these steps:
- Prerequisites: Install
Node.js & npm. - Installation:
npm install cypress typescriptdownloads Cypress and dependencies to anode_modulessubdirectory. - Configuration: Set up a Cypress typescript configuration file (
cypress.config.ts). - Writing Tests: Create test scenarios within the
cypress/e2edirectory. - Executing Tests:
npx cypress runto execute Cypress tests in headless mode.
The Cypress projects typically have a directory structure as follows:
cypress/: Cypress configuration and test files.e2e/: End-to-end test files specifically targeting the application's functionality.testcasefiles.cy.ts: End-to-end test specifications written in Cypress testing syntax.
fixtures/: Files used to mock data for testing.integration/: Standalone tests written in Cypress testing syntax.plugins/: Plugins used to extend Cypress's functionality.support/: Commands and custom Cypress configurations.e2e.ts: Functions specifically for end-to-end testing.commands.ts: Custom Cypress commands used in end-to-end testing.
node_modules: Automatically generated folder for the Node.js modules and dependencies.cypress.config.ts: Configuration settings for Cypress, written in TypeScript format.cypress.env.json: Cypress environmental variables (Ignored in repository).cypress.pipeline.env.json: CI/CD file used to overridecypress.env.jsonvariables.package.json: Project dependencies and metadata.package-lock.json: Automatically generated where npm modifies either thenode_modulestree orpackage.jsonfile.tsconfig.json: TypeScript transpiler configuration settings for the project.
The e2e/ folder is where you'll find test files that cover the end-to-end scenarios of the web application. These tests typically simulate user interactions with the application's UI to ensure that all components and features are working correctly.
The cypress.config.ts file allows customization of Cypress's behavior. Refer to the Cypress documentation for available configuration options.
To build and test the Cypress project using Azure DevOps and a Git repo, follow these steps:
- Source Repository: A Git repository branch containing the expected Cypress project files.
- Build Pipeline: Used to include project dependencies, execute token substitutions, and generate artifacts containing the end-to-end Cypress test directories.
- Release Pipeline: The release pipeline in Azure DevOps will deploy the published build artifact to one of the available build agents and further refine token substitutions based on the specific stage under test.
- Executing Tests: Execute headless Cypress tests as part of the deployment process on the build agent server.
- Viewing Results: After deployment, view test results and logs generated by Cypress on the build agent server.
These steps describe the build, deployment, and test run of a Cypress project using Azure DevOps.
The Cypress tests are integrated into the Azure DevOps CI/CD pipeline using Azure Pipelines. The CI/CD configuration includes trigger conditions, parallel execution, and other relevant settings defined in the Azure Pipelines.
Pipeline Release Task: Replace tokens in text based files:
with:
tokenPrefix: '{{'
tokenSuffix: '}}'
folder: $(System.DefaultWorkingDirectory)/$(Artifact)/TestRunner
files: '["**/*.ts"]'Test results and logs generated by Cypress are collected and reported using reporting tools integrated into the Azure DevOps pipeline.
Follow these best practices for writing efficient and maintainable Cypress tests:
- Use page objects to encapsulate page-specific functionality and selectors.
- Organize tests into logical suites based on functionality or user journeys.
- Use descriptive test names and comments to improve readability and maintainability.
Contributions to this project are welcome! Follow these guidelines when contributing:
- Report issues using Azure work items, providing clear and concise details.
- Submit pull requests with descriptive titles and a clear explanation of the proposed changes.
- Adhere to the coding standards and conventions used in the project.
This project is licensed under the terms of the MIT license.