Skip to content

Repository files navigation

🌦️ OpenWeatherMap API Test Automation Framework

Cypress JavaScript Reporter CI/CD License

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.


📌 Features & Test Coverage

This test framework delivers full test automation across multiple OpenWeatherMap API services and quality dimensions:

1. Multi-Endpoint Coverage

  • 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)
  • 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)

2. Quality Dimensions & Test Types

  • 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).

🏛️ Framework Architecture (Page Object Model)

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

🚀 Getting Started

1. Prerequisites

  • Node.js: v18+ (tested on v20 and v24)
  • npm: v9+

2. Installation

Clone the repository and install all dependencies:

git clone https://github.com/MHuzaifaAsif/weatherAPI_AutoTest.git
cd weatherAPI_AutoTest
npm install

🧪 Running Tests

Run All Tests (Headless)

npm test

Run Tests with Interactive Cypress UI

npm run test:open

Run Individual Test Suites

# 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:datadriven

📊 Test Reporting (Mochawesome)

Generate a single merged interactive HTML report complete with pass/fail charts and execution metrics:

npm run test:report

The generated report will be saved to:

cypress/reports/html/index.html

⚙️ Continuous Integration (CI/CD)

This project contains an automated GitHub Actions workflow (.github/workflows/api-tests.yml) that:

  1. Triggers on every push and pull_request to main/master.
  2. Installs dependencies in an isolated Ubuntu container.
  3. Executes the full Cypress API test suite.
  4. Generates and merges Mochawesome HTML reports.
  5. Uploads the HTML report as a downloadable artifact.

👤 Author

M_HUZAIFA ASIF


📄 License

This project is licensed under the ISC License.

About

Comprehensive REST API test automation framework for OpenWeatherMap built with Cypress, JavaScript (ES6+), Page Object Model (POM), Mochawesome reporting, and GitHub Actions CI/CD.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages