UI Testing Setup for Niamh Stockil Portfolio
UI Testing Setup for Niamh Stockil Portfolio
This project includes comprehensive UI testing with Cypress and accessibility testing with axe-core.
Prerequisites
- Ruby & Jekyll (already set up)
- Bundle install:
bundle install - Build site:
bundle exec jekyll build
- Bundle install:
- Node.js & npm (for testing tools)
- Install dependencies:
npm install
- Install dependencies:
Available Test Scripts
Local Development
# Install all dependencies
npm install
# Build Jekyll site and start local server
npm run build:serve
# Run Cypress tests interactively
npm run test:cypress:open
# Build site and run all tests
npm run test
Individual Test Types
# Run only Cypress e2e tests
npm run test:cypress
# Run only accessibility tests (requires server running)
npm run test:accessibility
# Build and serve site locally
npm run build:serve
CI/CD (GitHub Actions)
The .github/workflows/ui-tests.yml workflow runs automatically on push and includes:
- Jekyll Build - Builds the static site
- Accessibility Tests - Runs axe-core against all pages
- Cypress E2E Tests - Tests user flows and functionality
Test Structure
All testing assets are organized in the test/ directory:
test/
├── cypress.config.js # Cypress configuration
├── .axerc.json # Axe accessibility rules
├── cypress/
│ ├── support/
│ │ ├── e2e.js # Global test setup
│ │ └── commands.js # Custom commands
│ └── e2e/
│ ├── homepage.cy.js # Homepage functionality and SEO
│ ├── navigation.cy.js # Site navigation and routing
│ ├── blog.cy.js # Blog posts and RSS feeds
│ └── accessibility.cy.js # Accessibility compliance
└── reports/ # Generated test reports
Cypress Tests (test/cypress/e2e/)
homepage.cy.js- Homepage functionality and SEOnavigation.cy.js- Site navigation and routingblog.cy.js- Blog posts and RSS feedsaccessibility.cy.js- Accessibility compliance
Accessibility Tests
- Automated via axe-core CLI
- WCAG 2.1 AA compliance
- Color contrast, heading structure, alt text
- Configured in
test/.axerc.json
Configuration Files
test/cypress.config.js- Cypress configurationpackage.json- Dependencies and scriptstest/.axerc.json- Axe accessibility rulestest/cypress/support/- Custom commands and setup
Local Testing Workflow
- Build the Jekyll site:
npm run build - Start local server:
npm run serve(in separate terminal) - Run tests:
npm run test:cypressornpm run test:accessibility - For interactive testing:
npm run test:cypress:open
Adding New Tests
Cypress Tests
Add new test files to test/cypress/e2e/ following the naming pattern *.cy.js
Custom Commands
Add reusable test functions to test/cypress/support/commands.js
Page Objects
Consider creating page objects in test/cypress/support/pages/ for complex interactions
Troubleshooting
Common Issues
- Port 3000 in use: Change port in
test/cypress.config.jsand npm scripts - Jekyll build errors: Run
bundle exec jekyll doctor - Cypress installation: Run
npm run cy:install
Windows-Specific
- Server stopping: Uses
taskkillcommand - Timeout commands: Uses Windows
timeoutinstead ofsleep
Integration with VS Code
Recommended extensions:
- Cypress Helper
- axe DevTools
- Jekyll snippets