1 / 6

<br>Using Cypress.io with #GitHub Actions to automate tests on every commit is a powerful way to ensure that your hashtag#application remains stable as you develop.

Download Presentation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quality.Catalyzed Running Cypress Tests with GitHub Actions Step 1: Create Your Cypress Tests Ensure you have Cypress installed and your tests set up in your project. You can add Cypress to your project using npm: npm install cypress --save-dev Create your tests in the cypress/e2e folder. www.testrigtechnologies.com

  2. Quality.Catalyzed Step 2: Create a GitHub Actions Workflow Create the Workflow File: In your repository, create a new directory called .github/workflows. Inside this directory, create a file named cypress.yml. Add the Workflow Configuration: Open the cypress.yml file and add the following content: name: Cypress Tests on: push: branches: - main # Set the branch where the tests should run pull_request: branches: - main jobs: cypress-run: runs-on: ubuntu-latest www.testrigtechnologies.com

  3. Quality.Catalyzed steps: - name: Checkout Code uses: actions/checkout@v2 - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '14' # Use the version of Node.js you require - name: Install Dependencies run: | npm install - name: Run Cypress Tests run: | npx cypress run Step 3: Customize Your Workflow Node Version: Update the node-version under setup-node to match the version used in your project. www.testrigtechnologies.com

  4. Quality.Catalyzed Branch Configuration: You can modify the branches under push and pull_request to specify where you want the tests to run. Specification of Env: user can specify the env on which they want to execute the test as per the requirements npm run -- command name Step 4: Commit Your Workflow Save the cypress.yml file and commit it to your repository: git add .github/workflows/cypress.yml git commit -m "Add Cypress testing workflow" git push origin main www.testrigtechnologies.com

  5. Quality.Catalyzed Step 5: Verify Your Setup Push to GitHub: Whenever you push changes to the specified branches or create a pull request, GitHub Actions will trigger the Cypress tests. Check the Actions Tab: Go to the “Actions” tab in your GitHub repository to see the running workflow. Click on the workflow to view the logs and see if your tests passed or failed. Step 6: Set Up Environment Variables (Optional) If your tests require any environment variables (like API keys or secrets), you can set these up in your GitHub repository settings: 1. 2. Go to Settings > Secrets and variables > Actions. Click on New repository secret to add your secrets. www.testrigtechnologies.com

  6. Quality.Catalyzed In your workflow file, you can access these secrets like this: - name: Run Cypress Tests env: MY_SECRET: ${{ secrets.MY_SECRET }} run: | npx cypress run www.testrigtechnologies.com

More Related