This directory contains integration tests for the Zest Spec CLI.
The suite uses the built-in Node.js test runner (node:test).
The test system follows a separation of concerns design:
- Test Cases (what to test): Defined in
test-integration.jswithnode:test - Test Environment (where to test): Controlled by setup scripts and npm commands
This separation makes tests maintainable and ensures the same test suite runs in both local development and packaged environments.
Core integration test suite that verifies CLI functionality.
What it tests:
- Command output format (YAML structure)
- Directory structure creation
- Command file deployment
- Skills deployment
- Frontmatter transformation
- Content preservation
- Idempotency (running init multiple times)
Key principle: This test file contains only test logic, no environment setup.
Environment setup script that creates a clean package installation.
What it does:
- Packs the CLI with
npm pack - Creates a fresh npm environment
- Installs the packaged CLI from tarball
- Verifies basic CLI functionality
Key principle: This script only sets up the environment, doesn't run tests.
npm test
# or
npm run test:localPrerequisites:
- Node.js 20+ (for the built-in test runner)
- Tests run against your local development code
npm run test:packageWhat happens:
- CLI is packed into a tarball
- Fresh environment is created in
test-package-env/ - Tarball is installed as an npm package
- Same test suite from
test-integration.jsruns
Why this matters: Catches issues with package.json files field that local testing misses.
The CI workflow runs two parallel jobs with the same test suite but different environments:
- Install dependencies (pnpm install)
- Run tests (pnpm test:local)Purpose: Fast feedback on logic errors and functionality issues
- Install dependencies (pnpm install)
- Setup package environment and run tests (pnpm test:package)Purpose: Verify packaging configuration and catch distribution issues
Key difference: GitHub Actions only controls the environment setup. All test logic lives in JS files, not YAML.
{
"files": [
"bin/",
"lib/"
// ❌ Forgot to include "plugin/" directory
]
}Result:
- ✅ Local tests pass (files exist in your repo)
- ❌ Package tests fail (files not included in tarball)
- ❌ Users can't use the CLI after installing
{
"files": [
"src/bin/", // ❌ Wrong path (should be "bin/")
"lib/"
]
}If code requires a dependency not in package.json, package tests catch it.
# Run local tests (fast)
npm test# Run package tests (thorough)
npm run test:package- Add test cases to
test-integration.js - Tests automatically run in both environments
- No need to modify GitHub Actions
Inspect package contents:
npm pack
tar -tzf zest-dev-*.tgzCheck installed package structure:
ls -la test-package-env/node_modules/zest-dev/- DRY (Don't Repeat Yourself): Test cases written once, run everywhere
- Separation of Concerns: Test logic separate from environment setup
- Maintainability: Adding tests doesn't require touching GitHub Actions
- Clarity: Each file has a single, clear responsibility