An enterprise-grade, comprehensive REST API Automation Testing Framework built for OpenWeatherMap API using Cypress, JavaScript (ES6+), and the Page Object Model (POM) design pattern.
This test framework delivers full test automation across multiple OpenWeatherMap API services and quality dimensions:
- Current Weather Data (
/data/2.5/weather):- Query by City Name, City & Country Code (
q=Lahore,PK) - Query by Geographic Coordinates (
lat,lon) - Multi-unit measurement systems (
metric,imperial,standard) and temperature mathematical consistency - Multi-language support (
lang=es, fr, de, ur, ar, ja) - Meteorological physics checks (
sunrise < sunset,humidity: 0-100%,pressure: 500-1200 hPa)
- Query by City Name, City & Country Code (
- 5-Day / 3-Hour Forecast (
/data/2.5/forecast):- 40 interval forecast blocks verification
- Strictly ascending chronological timestamps (
dt,dt_txt) - Interval progression check (10,800s / 3-hour increments)
- Count limitation parameter (
cnt)
- Air Pollution API (
/data/2.5/air_pollution):- Air Quality Index (AQI 1-5 scale) verification
- Individual pollutant concentrations (
CO, NO, NO2, O3, SO2, PM2.5, PM10, NH3) - Upcoming days air pollution forecast
- Geocoding API (
/geo/1.0/):- Direct Geocoding (City name to latitude/longitude)
- Reverse Geocoding (Coordinates to City Name & Country)
- ZIP / Postal Code Geocoding (
10001, US,SW1A 1AA, GB)
- Negative & Boundary Testing: Non-existent cities (404), empty parameters (400), out-of-range coordinates (400), invalid/missing API keys (401).
- Security & Injection Robustness: Sanitization testing against SQL Injection, XSS
<script>payloads, Path Traversal, and URL-encoded special characters without causing 500 server crashes. - Schema Contract Validation: Verifies complete response structures, keys, and data types against JSON schema definitions.
- Performance SLAs: Response latency assertions (< 2000ms SLA threshold) and HTTP header inspections (
Content-Type: application/json,Server,Date). - Data-Driven Testing (DDT): Parameterized test execution iterating over Cypress fixtures (
cities.json,coordinates.json,negativeData.json).
weatherAPI_AutoTest/
├── .github/
│ └── workflows/
│ └── api-tests.yml # GitHub Actions CI/CD pipeline
├── cypress/
│ ├── e2e/
│ │ ├── 01_current_weather.cy.js # Current weather functional tests
│ │ ├── 02_forecast_api.cy.js # 5-Day / 3-hour forecast tests
│ │ ├── 03_air_pollution_api.cy.js # Air pollution & AQI tests
│ │ ├── 04_geocoding_api.cy.js # Direct, reverse & ZIP geocoding
│ │ ├── 05_negative_and_security.cy.js # Boundary, auth & security tests
│ │ ├── 06_schema_and_performance.cy.js# Contract & SLA latency tests
│ │ ├── 07_data_driven_tests.cy.js # Data-driven fixture tests
│ │ └── weatherAPItest.cy.js # Backward-compatible suite
│ ├── fixtures/
│ │ ├── cities.json # Global cities dataset
│ │ ├── coordinates.json # Extreme & benchmark coordinates
│ │ ├── negativeData.json # Error & malicious test payloads
│ │ ├── weatherSchema.json # Current weather JSON schema
│ │ ├── forecastSchema.json # Forecast JSON schema
│ │ └── airPollutionSchema.json # Air pollution JSON schema
│ ├── pages/
│ │ ├── BaseAPI.js # Base POM with request wrapper
│ │ ├── weatherAPI.js # Current Weather POM
│ │ ├── ForecastAPI.js # Forecast POM
│ │ ├── AirPollutionAPI.js # Air Pollution POM
│ │ └── GeoAPI.js # Geocoding POM
│ └── support/
│ ├── commands.js # Custom assertions & commands
│ └── e2e.js # Global setup & configurations
├── cypress.config.js # Cypress test runner config
├── package.json # NPM dependencies & test scripts
└── README.md # Documentation
- Node.js: v18+ (tested on v20 and v24)
- npm: v9+
Clone the repository and install all dependencies:
git clone https://github.com/MHuzaifaAsif/weatherAPI_AutoTest.git
cd weatherAPI_AutoTest
npm installnpm testnpm run test:open# Current Weather Suite
npm run test:weather
# 5-Day Forecast Suite
npm run test:forecast
# Air Pollution & AQI Suite
npm run test:pollution
# Geocoding Suite
npm run test:geo
# Negative & Security Suite
npm run test:negative
# Schema & Performance SLA Suite
npm run test:schema
# Data-Driven Test Suite
npm run test:datadrivenGenerate a single merged interactive HTML report complete with pass/fail charts and execution metrics:
npm run test:reportThe generated report will be saved to:
cypress/reports/html/index.html
This project contains an automated GitHub Actions workflow (.github/workflows/api-tests.yml) that:
- Triggers on every
pushandpull_requesttomain/master. - Installs dependencies in an isolated Ubuntu container.
- Executes the full Cypress API test suite.
- Generates and merges Mochawesome HTML reports.
- Uploads the HTML report as a downloadable artifact.
M_HUZAIFA ASIF
- GitHub: @MHuzaifaAsif
- Email: asifhuzaifa328@gmail.com
This project is licensed under the ISC License.