A CLI Tool for AI-Powered Web Platform Test Generation
Project description
WPT-Gen: AI-Powered Web Platform Test Generation
WPT-Gen is an agentic CLI tool designed to increase browser interoperability by automating the creation of Web Platform Tests (WPT).
By bridging the gap between W3C Specifications and local WPT repositories, WPT-Gen uses Large Language Models (LLMs) to proactively identify testing gaps and generate high-quality, compliant test cases.
Why WPT-Gen?
Browser interoperability is critical for the web. While the W3C and WHATWG write specifications, there is often a gap between those specs and the tests that ensure browsers implement them correctly. WPT-Gen bridges this gap by:
- Reducing Manual Effort: Automating the tedious process of mapping spec assertions to existing tests.
- Ensuring High Coverage: Identifying missing edge cases and suggesting specific test scenarios.
- Standardizing Compliance: Generating tests that adhere to strict WPT style guides and directory structures.
Key Features
- Context Assembly: Automatically resolves Web Feature IDs (via
web-features) to fetch specification and MDN documentation (if available), using BeautifulSoup and Markdownify to preserve critical code blocks and semantic structure. - Deep Local Analysis: Scans your local WPT repository using
WEB_FEATURES.ymlmetadata to identify existing tests and their dependencies. - Gap Analysis: Compares technical requirements synthesized from specifications against current test coverage to pinpoint missing assertions.
- Test Suggestions: Brainstorms specific, actionable test scenarios (blueprints) that address identified gaps.
- Automated Generation: Produces atomic, WPT-compliant HTML and JavaScript test files based on user-approved blueprints using an autonomous agent powered by
google-adk. - Multi-Provider Support: Built-in support for Google Gemini (via
google-genaiand thinking models), OpenAI, and Anthropic models.
How it Works
WPT-Gen follows a structured, multi-phase agentic workflow. Each phase is designed to build upon the last, culminating in high-quality, verified test cases.
flowchart TD
subgraph Context[Context Assembly]
A[Web Features] --> B[Scrape Specs/MDN]
C[Local WPT Repo] --> D[Index Existing Tests]
end
subgraph Analysis[Requirement & Gap Analysis]
B & D --> E{{Requirements Extraction}}
E --> F{{Coverage Audit}}
F --> G[Test Blueprints]
end
subgraph Generation[Test Generation]
G --> H{{Test Generation}}
end
classDef llm fill:#4B0082,stroke:#333,stroke-width:2px;
class E,F,H llm;
Workflow Phases
For an in-depth explanation of the internal logic, inputs, outputs, and LLM integrations for each phase, see the Workflow Phases Documentation.
- Phase 1: Context Assembly: Aggregates the "Source of Truth" from external documentation (W3C Specs, MDN) and identifies existing test coverage in the local WPT repository.
- Phase 2: Requirements Extraction: Uses an LLM to synthesize specification text into structured, granular technical requirements. Supports parallel and iterative extraction modes for complex specs.
- Phase 3: Coverage Audit: Performs a delta analysis by comparing the synthesized requirements against the local test suite. This phase outputs an audit worksheet and high-level test blueprints.
- Phase 4: Test Generation: Translates user-selected blueprints into functional WPT-compliant code (JavaScript, Reftests, or Crashtests) using an autonomous agent powered by
google-adk, which leverages specialized file-system tools and style guide instructions.
Prerequisites
- Python 3.10+
- Local WPT Repository: A local checkout of web-platform-tests/wpt.
- API Key: An API key for a supported LLM (Gemini, OpenAI, or Anthropic).
Installation
From PyPI (Recommended)
pip install wpt-gen
From Source (Development)
# Clone the repository
git clone https://github.com/GoogleChromeLabs/wpt-gen.git
cd wpt-gen
# Install the package (using a virtual environment is recommended)
python -m venv .venv
source .venv/bin/activate
make install
Configuration
WPT-Gen uses a combination of a YAML configuration file and environment variables.
1. Environment Variables
You must export the API key for your chosen provider. These are never stored on disk.
export GEMINI_API_KEY="your_gemini_api_key"
# OR
export OPENAI_API_KEY="your_openai_api_key"
# OR
export ANTHROPIC_API_KEY="your_anthropic_api_key"
2. YAML Configuration (wpt-gen.yml)
Run wpt-gen init to generate a wpt-gen.yml configuration file with sensible defaults:
wpt-gen init --wpt-path /path/to/your/local/wpt
This will create a configuration file that looks like this:
default_provider: gemini
wpt_path: /path/to/your/local/wpt # Path to your local WPT checkout
providers:
gemini:
default_model: gemini-3.1-pro-preview
categories:
lightweight: gemini-3-flash-preview
reasoning: gemini-3.1-pro-preview
openai:
default_model: gpt-5.2-high
categories:
lightweight: gpt-5-mini
reasoning: gpt-5.2-high
anthropic:
default_model: claude-opus-4-6
categories:
lightweight: claude-sonnet-4-6
reasoning: claude-opus-4-6
phase_model_mapping:
requirements_extraction: reasoning
coverage_audit: reasoning
generation: lightweight
3. Managing Configuration via CLI
You can use the built-in config command group to view or modify your settings without opening the YAML file manually.
- View Configuration:
wpt-gen config show
- Update Configuration: Use dot-notation to set specific values.
wpt-gen config set default_provider "openai" wpt-gen config set providers.gemini.default_model "gemini-3.1-pro-preview"
Usage
The primary interface is the generate command, which requires a Web Feature ID (as defined in the web-features repository).
Basic Generation
wpt-gen generate font-family
Common Options
| Option | Shorthand | Description |
|---|---|---|
web_feature_id |
(Arg) | Required. The ID of the feature (e.g., font-family, popover). |
--provider |
-p |
Override the default LLM provider (gemini, openai, anthropic). |
--wpt-dir |
-w |
Override the path to the local web-platform-tests repository. |
--draft |
Enable fetching metadata from the draft features directory. | |
--config |
-c |
Path to a custom wpt-gen.yml file. |
Note: You can run wpt-gen generate --help to see a full list of all 20+ options (including manual overrides). For more detailed information, see the CLI Command Reference.
Other Commands
wpt-gen clear-cache: Clears local cache of specs and LLM responses.wpt-gen version: Displays the current version.
Development
Running Tests
We use pytest for unit and integration testing. Run tests easily via:
make test
Linting & Formatting
We use ruff to maintain code quality and mypy for type checking. You can run these using make commands:
# Lint and format
make lint-fix
# Type check
make typecheck
# Run all checks (format, lint, typecheck, tests)
make check
# Prepare for PR (runs lint-fix, typecheck, and test)
make presubmit
Release Process
WPT-Gen utilizes a CI/CD pipeline via GitHub Actions. Creating and publishing a new GitHub Release (e.g., v1.0.0) automatically triggers the publish.yml workflow, which securely builds and uploads the package to PyPI. For more details, see the Contributing Guide.
AI Assistant Integration
This repository includes a GEMINI.md and a suite of AI skills in the .agents/skills/ directory to help AI assistants (like Gemini Code Assist) better understand the project's architecture, dependencies, and testing standards. You can point your AI assistant to GEMINI.md for a comprehensive overview of how to contribute accurately to the codebase.
License
Apache 2.0. See LICENSE for more information.
Source Code Headers
Every file containing source code must include copyright and license information.
Apache header:
Copyright 2026 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wpt_gen-0.3.0.tar.gz.
File metadata
- Download URL: wpt_gen-0.3.0.tar.gz
- Upload date:
- Size: 142.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91925a1e8d1de49eae7341cc84be201dfd83dd581c8828513c23e5ea9791a337
|
|
| MD5 |
4869607c12100d4551e6b3d3684edf0a
|
|
| BLAKE2b-256 |
929013ca0a67eb4ac787bde9c4cb5c04e68b153a317f86161f00ce92c9e8a4eb
|
Provenance
The following attestation bundles were made for wpt_gen-0.3.0.tar.gz:
Publisher:
publish.yml on GoogleChromeLabs/wpt-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wpt_gen-0.3.0.tar.gz -
Subject digest:
91925a1e8d1de49eae7341cc84be201dfd83dd581c8828513c23e5ea9791a337 - Sigstore transparency entry: 1189465692
- Sigstore integration time:
-
Permalink:
GoogleChromeLabs/wpt-gen@028e69fe8ea1a2449825bc524832f1a4b79d73b0 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/GoogleChromeLabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@028e69fe8ea1a2449825bc524832f1a4b79d73b0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wpt_gen-0.3.0-py3-none-any.whl.
File metadata
- Download URL: wpt_gen-0.3.0-py3-none-any.whl
- Upload date:
- Size: 131.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f746276a7329ce899de80342ad24b1d1f2d3a8796d533ac352161cfec4ce2d7e
|
|
| MD5 |
fcfd147e46a029d0e930e0575d6eea10
|
|
| BLAKE2b-256 |
335cedca8abccfa51527dbf8201bf6ee504135ed6ad756e04ba189b9f72e0ed9
|
Provenance
The following attestation bundles were made for wpt_gen-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on GoogleChromeLabs/wpt-gen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wpt_gen-0.3.0-py3-none-any.whl -
Subject digest:
f746276a7329ce899de80342ad24b1d1f2d3a8796d533ac352161cfec4ce2d7e - Sigstore transparency entry: 1189465696
- Sigstore integration time:
-
Permalink:
GoogleChromeLabs/wpt-gen@028e69fe8ea1a2449825bc524832f1a4b79d73b0 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/GoogleChromeLabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@028e69fe8ea1a2449825bc524832f1a4b79d73b0 -
Trigger Event:
release
-
Statement type: