Sakai Monthly Patch Update: April 2025
Automating Regression Testing with Cypress and GitHub Actions
Dec 14, 2024 Open Source

Automating Regression Testing with Cypress and GitHub Actions

Stop manual checking and let your CI catch regressions before they reach production. Learn how to integrate Cypress end-to-end tests into GitHub Actions for reliable, repeatable regression testing.

Introduction

As your application grows, manual regression testing becomes unsustainable. Cypress provides rock-solid browser automation, while GitHub Actions runs your suite on every pull request and push. Together, they create a continuous guardrail against unexpected breakages.

Why Automate Regression Testing?

  • Catch Breakages Early
    Every commit triggers a full regression suite—no more “it worked on my machine.”
  • Consistent Environments
    CI runners use the same browser versions and OS, eliminating local drift.
  • Faster Feedback
    Developers get pass/fail results in minutes, reducing context-switching.

Setting Up Cypress

  1. Install dependencies
    npm install --save-dev cypress
    # or
    yarn add --dev cypress
  2. Initialize config
    npx cypress open
  3. Configure base URL (in cypress.config.js)
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    baseUrl: 'http://localhost:3000',
    specPattern: 'cypress/e2e/**/*.cy.{js,ts}'
  }
})

Writing Regression Tests

Place your critical “happy-path” and edge-case flows under cypress/e2e/regression/:

// cypress/e2e/regression/login.cy.js
describe('Regression: Login Flow', () => {
  beforeEach(() => {
    cy.visit('/login')
  })

  it('logs in with valid credentials', () => {
    cy.get('input[name="email"]').type('user@example.com')
    cy.get('input[name="password"]').type('correct horse battery staple')
    cy.get('button[type="submit"]').click()
    cy.url().should('include', '/dashboard')
    cy.contains('Welcome back').should('be.visible')
  })

  it('shows error on invalid password', () => {
    cy.get('input[name="email"]').type('user@example.com')
    cy.get('input[name="password"]').type('wrongpassword')
    cy.get('button[type="submit"]').click()
    cy.contains('Invalid credentials').should('be.visible')
  })
})

Integrating with GitHub Actions

Create a workflow file under .github/workflows/cypress-regression.yml:

name: Regression Tests

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  cypress:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Start application
        run: npm start &
        env:
          CI: true

      - name: Wait for server
        uses: jakejarvis/wait-action@v1
        with:
          timeout: '60'     # seconds
          check-url: 'http://localhost:3000'

      - name: Run Cypress regression suite
        uses: cypress-io/github-action@v5
        with:
          start: npm start
          wait-on: 'http://localhost:3000'
          spec: 'cypress/e2e/regression/**/*.cy.{js,ts}'

      - name: Upload test artifacts
        if: failure()
        uses: actions/upload-artifact@v3
        with:
          name: cypress-videos
          path: cypress/videos

How it works

  • Checkout & install with caching.
  • Start your app in the background.
  • Wait until the server responds.
  • Invoke Cypress Action to run only the regression specs.
  • Upload artifacts (videos, screenshots) on failure for debugging.

Best Practices

  • Isolate Tests: Keep regression specs focused on critical flows.
  • Tag & Filter: Use .only or CI-specific tags (@regression) to limit scope.
  • Parallelization: Leverage Cypress Dashboard or GitHub matrix to split heavy suites.
  • Flake Reduction: Use stable selectors (data-cy attributes) and avoid network randomness.

Conclusion

Embedding Cypress regression tests into GitHub Actions gives your team confidence that every change is safe. With a few lines of YAML and your existing specs, you’ll catch regressions before they reach users—automatically and consistently.

Related Articles

Migrating from Nginx to Caddy
April 23, 2025 Open Source

Migrating from Nginx to Caddy

Switching from Nginx? Caddy offers a simpler, more secure way to manage reverse proxies, especially for setups like Tomcat load-balancing. Learn how its Go-based design and strong community support can benefit your stack.

Automating Accessibility Compliance with Cypress
March 23, 2025 Accessibility

Automating Accessibility Compliance with Cypress

Catch accessibility issues early in your development workflow by integrating automated checks into your end-to-end tests. Learn how Cypress and the cypress-axe plugin can help you enforce WCAG standards continuously, from local development through CI pipelines.

Powering UI with Lit Web Components
Jan 10, 2025 Open Source

Powering UI with Lit Web Components

Discover how Sakai leverages Lit’s lightweight, standards-based web components to build a scalable, maintainable, and high-performance LMS interface for universities and enterprises.

Ready to transform your educational technology?

Whether you're a small school, an educational startup, or a large institution, our open-source solutions can be tailored to meet your specific needs and budget.