Automatically verifies that all public functions in phantom.js have corresponding test cases in phantom.test.js.
- ✅ Detects all public functions in
phantom.js - ✅ Checks if corresponding tests exist
- ✅ Diff mode: Only checks new functions added in PRs
- ✅ Strict mode: Fails if any functions are missing tests
- ✅ Beautiful colored output
# Check all functions
npm run test:check
# Check only new functions (diff mode)
npm run test:check-diff
# Strict mode (fails on missing tests)
npm run test:check -- --strict-
Function Detection: Extracts all public functions from
phantom.jsusing patterns:phantom.category.operation.functionNamephantom.category.functionNamephantom.init
-
Test Detection: Finds all test cases in
phantom.test.js:test('description', ...)describe('suite', ...)
-
Matching: Checks if each function has a corresponding test by:
- Direct name match
- Test description contains function name
- Module-level test coverage
-
Diff Mode: When using
--diff, compares current code with base branch to only validate new functions.
The script runs automatically on:
- Pull Requests: Checks only new functions added
- Main branch: Validates all functions
If new functions are added without tests, the CI will fail and prevent merging.
🔍 Checking Test Coverage...
┌─ Test Coverage Report ────────────────────────────────┐
│ Total functions checked: 104 │
│ ✓ Covered: 104 │
│ ✗ Missing tests: 0 │
└─────────────────────────────────────────────────────┘
Coverage: 100.0%
✅ All functions have test coverage!
Creates a release package (zip file) containing only phantom.js and phantom.min.js for distribution.
- ✅ Automatically reads version from
package.json - ✅ Generates minified file if missing
- ✅ Creates zip archive with only essential files
- ✅ Works in CI/CD environments
# Create release package
npm run release
# Or directly
node scripts/create-release.jsCreates release/phantom-v<VERSION>.zip containing:
phantom.js(readable source)phantom.min.js(minified version)
Complete release preparation workflow that automates the entire release process.
- ✅ Runs all tests
- ✅ Verifies test coverage
- ✅ Generates minified file
- ✅ Creates release package
- ✅ Creates Git tag
- ✅ Provides next steps
# Prepare complete release
npm run release:prepare- Run Tests: Executes all test suites
- Check Coverage: Verifies 100% test coverage
- Generate Minified: Creates
phantom.min.js - Create Package: Generates release zip file
- Create Tag: Creates Git tag with version
- Instructions: Shows next steps for pushing
🚀 Preparing Release...
📦 Version: 0.1.4-BETA
🏷️ Tag: v0.1.4-BETA
1️⃣ Running tests...
2️⃣ Checking test coverage...
3️⃣ Generating minified file...
4️⃣ Creating release package...
5️⃣ Checking Git tag...
✓ Tag created: v0.1.4-BETA
✅ Release preparation complete!
📋 Next steps:
1. Review the release package
2. Push the tag to GitHub:
git push origin v0.1.4-BETA
3. GitHub Actions will automatically create the release
When you push a tag (e.g., v0.1.4-BETA), GitHub Actions automatically:
- ✅ Checks out the code
- ✅ Installs dependencies
- ✅ Generates minified file
- ✅ Creates release package
- ✅ Creates GitHub Release with:
- Release notes from
docs/RELEASE_NOTES_v<VERSION>.md - Zip file attachment
- Pre-release flag for BETA/ALPHA/RC versions
- Auto-generated release notes
- Release notes from
# 1. Prepare release (runs tests, creates package, creates tag)
npm run release:prepare
# 2. Push tag to GitHub (triggers automatic release)
git push origin v0.1.4-BETA
# 3. GitHub Actions automatically creates the release!If you prefer to create releases manually:
- Create release package:
npm run release - Create tag:
git tag -a v0.1.4-BETA -m "Release message" - Push tag:
git push origin v0.1.4-BETA - Create release on GitHub: https://github.com/OS366/phantom/releases/new
- Upload the zip file from
release/directory
When adding a new function to phantom.js:
- Add the function following the pattern:
phantom.category.operation.functionName - Add corresponding test cases in
phantom.test.js - Run
npm run test:check-diffto verify - The CI will automatically check on PR creation
If you forget to add tests, the CI will fail with a clear message showing which functions need tests.