How to Create Test Packages
This guide walks through creating Test Packages for different scenarios.
Basic Package Creation
Using the Scaffold
The scaffold command creates the complete package structure for you:
Test Package (E2E tests)
# Scaffold a test package with Playwright setup
qit package:scaffold tests/e2e --package=my-plugin/e2e
This creates:
qit-test.jsonwithrunphase andresultspackage.jsonwith Playwright dependenciesplaywright.config.jswith CTRF, Allure, and blob reporterstests/example.spec.jsstarter testbootstrap/shell scripts for setup/teardown
Utility Package (setup/configuration only)
# Scaffold a utility package (no tests, just setup)
qit package:scaffold utilities/setup \
--package=my-plugin/setup --package-type=utility
This creates:
qit-test.jsonwith setup phases only (norunphase)bootstrap/shell scripts for setup/teardown- No Playwright or npm dependencies
Scaffold Options
# Create manifest only (skip npm install)
qit package:scaffold tests/e2e \
--package=my-plugin/e2e --only-manifest
# Include JSON schema for IDE validation
qit package:scaffold tests/e2e \
--package=my-plugin/e2e --with-schema
If you omit --package, the scaffold command will prompt interactively.
Manual Creation
Create the essential files:
- qit-test.json - Package manifest
- playwright.config.js - Playwright configuration (test packages only)
- tests/ - Your test files (test packages only)
Package Types
Standard Test Package
Tests that produce results:
{
"package": "my-plugin/e2e",
"package_type": "test",
"test_type": "e2e",
"test": {
"phases": {
"run": ["npx playwright test"]
},
"results": {
"ctrf-json": "./results/ctrf.json",
"blob-dir": "./results/blob"
}
}
}
Utility Package
Setup without tests:
{
"package": "my-plugin/setup",
"package_type": "utility",
"test": {
"phases": {
"globalSetup": ["./bootstrap/global-setup.sh"],
"setup": ["./bootstrap/setup.sh"]
}
}
}
Commands ending in .sh run inside the Docker container (where WordPress lives). Other commands run on the host. Put WP-CLI commands inside shell scripts:
# bootstrap/global-setup.sh
#!/bin/bash
set -euo pipefail
wp plugin activate my-plugin
wp option set my_plugin_configured yes
In Playwright tests, use qit.wp() from @woocommerce/qit-runtime to run WP-CLI commands without writing shell scripts:
await qit.wp('option set my_plugin_configured yes');
Note: Utility packages do NOT include:
test_typefieldrunphaseresultsconfiguration
Best Practices
- Keep tests focused on one feature
- Use descriptive test names
- Include clear documentation
- Specify requirements explicitly