Acceptance Testing Framework
Acceptance Testing Framework
Section titled “Acceptance Testing Framework”The acceptance testing framework provides end-to-end validation of puppeteer-mcp’s capabilities by testing against publicly available, stable websites and APIs. These tests ensure that the system works correctly in real-world scenarios.
Test Structure
Section titled “Test Structure”Test Categories
Section titled “Test Categories”-
Basic Web Interactions (
tests/acceptance/basic/
)- Navigation and page loading
- Form filling and submission
- Element selection and interaction
- Content extraction and validation
-
API Interactions (
tests/acceptance/api/
)- REST API calls and responses
- HTTP method testing
- Error handling and status codes
- Data parsing and validation
-
Complex Workflows (
tests/acceptance/workflows/
)- E-commerce complete purchase flows
- Authentication and session management
- Multi-step business processes
- State management across pages
Test Targets
Section titled “Test Targets”All tests use publicly available, testing-friendly targets:
- E-commerce: Sauce Demo, Automation Practice
- APIs: HTTPBin, JSONPlaceholder, ReqRes, World Bank API
- Testing Sites: The Internet, UI Testing Playground, DemoQA
- Real-world: Hacker News, Angular/React demos
See testing-targets-reference.md
for complete list and details.
Running Tests
Section titled “Running Tests”Local Development
Section titled “Local Development”# Run all acceptance testsnpm run test:acceptance
# Run specific test categoriesnpm run test:acceptance:basicnpm run test:acceptance:apinpm run test:acceptance:workflows
# Run with debugging (visible browser)ACCEPTANCE_TEST_HEADLESS=false npm run test:acceptance:basic
# Run with slow motion for debuggingACCEPTANCE_TEST_SLOW_MO=100 npm run test:acceptance:basic
Environment Variables
Section titled “Environment Variables”Variable | Description | Default |
---|---|---|
ACCEPTANCE_TEST_TIMEOUT | Test timeout in ms | 60000 |
ACCEPTANCE_TEST_RETRIES | Number of retries for flaky tests | 2 |
ACCEPTANCE_TEST_HEADLESS | Run in headless mode | true |
ACCEPTANCE_TEST_SLOW_MO | Slow down actions in ms | 0 |
CI/CD Integration
Section titled “CI/CD Integration”Acceptance tests run:
- Manual: Via GitHub Actions workflow dispatch
- Scheduled: Weekly on Sundays at 6 AM UTC
- Optional: Can be triggered for specific test suites
# GitHub Actions provides these options:# - Test suite selection (all, basic, api, workflows)# - Headless mode toggle# - Custom timeout settings
Test Framework Components
Section titled “Test Framework Components”MCP Client Utilities (utils/mcp-client.ts
)
Section titled “MCP Client Utilities (utils/mcp-client.ts)”Provides high-level MCP interaction methods:
createMCPClient()
: Start MCP server and connect clientcreateMCPSession()
: Create browser session and contextmcpNavigate()
,mcpClick()
,mcpType()
: Browser actionsmcpGetContent()
,mcpScreenshot()
: Data extractioncleanupMCPSession()
: Resource cleanup
Test Helpers (utils/test-helpers.ts
)
Section titled “Test Helpers (utils/test-helpers.ts)”Common utilities for robust testing:
retryOperation()
: Retry with exponential backoffwaitForCondition()
: Polling for conditionsmakeRequest()
: HTTP requests with retry logicPerformanceTracker
: Timing and performance measurementAssertionHelpers
: Specialized assertion methods
Configuration (utils/test-config.ts
)
Section titled “Configuration (utils/test-config.ts)”Centralized configuration for:
- Test timeouts and retry settings
- Target URLs and endpoints
- Test credentials for demo sites
- Browser and viewport settings
Best Practices
Section titled “Best Practices”Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Debugging Commands
Section titled “Debugging Commands”# Run with visible browser and slow motionACCEPTANCE_TEST_HEADLESS=false ACCEPTANCE_TEST_SLOW_MO=250 npm run test:acceptance:basic
# Run single test filenpx jest --config jest.acceptance.config.mjs tests/acceptance/basic/navigation.test.ts
# Collect detailed logsDEBUG=puppeteer:* npm run test:acceptance:basic
Configuration Files
Section titled “Configuration Files”File | Purpose |
---|---|
jest.acceptance.config.mjs | Jest configuration for acceptance tests |
package.json | Test scripts and dependencies |
.github/workflows/acceptance-tests.yml | CI/CD workflow |
tests/acceptance/utils/ | Framework utilities and configuration |
Maintenance
Section titled “Maintenance”Adding New Tests
Section titled “Adding New Tests”- Follow existing patterns in test categories
- Use stable, public testing targets
- Implement proper retry and error handling
- Add performance tracking for critical paths
- Document any new test targets in the reference
Updating Test Targets
Section titled “Updating Test Targets”- Validate new targets for stability and accessibility
- Add to
test-config.ts
with appropriate categorization - Test against new targets before committing
- Update documentation with any special considerations
Monitoring
Section titled “Monitoring”- Tests run weekly to catch regressions
- Artifacts collected on failures for debugging
- Performance metrics tracked over time
- External service health monitored
Integration with Development Workflow
Section titled “Integration with Development Workflow”Acceptance tests complement the existing test suite:
Test Type | Purpose | Scope |
---|---|---|
Unit Tests | Fast, isolated component testing | Individual functions |
Integration Tests | Internal API and component integration | System components |
Acceptance Tests | Real-world end-to-end validation | Complete workflows |
Security Tests | Automated security scanning | Security compliance |
This multi-layered approach ensures comprehensive coverage from individual functions to complete user workflows.
Future Enhancements
Section titled “Future Enhancements”Planned improvements to the acceptance testing framework:
- Visual Regression Testing: Screenshot comparison across runs
- Performance Benchmarking: Automated performance regression detection
- Mobile Testing: Mobile browser and responsive design validation
- Accessibility Testing: Automated accessibility compliance checking
- Load Testing: Concurrent session and performance testing
Related Documentation
Section titled “Related Documentation”- Testing Overview for complete testing strategy
- Security Testing for security validation
- Performance Testing for performance validation
- UX Testing for user experience validation
Conclusion
Section titled “Conclusion”The acceptance testing framework provides confidence that puppeteer-mcp works correctly in real-world scenarios while maintaining reliability and performance standards. By testing against stable public targets with robust retry mechanisms and comprehensive monitoring, the framework ensures system reliability in production environments.