The OpenCode test suite validates the Superpowers plugin integration with the OpenCode.ai platform. It verifies plugin loading, skills-core.js library functions, tool integration, and skill priority resolution through a combination of unit tests (no external dependencies) and integration tests (require OpenCode installation).
For Claude Code-specific testing, see Claude Code Test Suite. For end-to-end workflow validation, see Integration Test Cases.
The OpenCode test suite uses a modular design with isolated test environments and clear separation between unit tests and integration tests.
Test Runner Command Structure
Sources: tests/opencode/run-tests.sh1-166
The setup.sh script creates an isolated test environment for reproducible testing without affecting the user's actual OpenCode installation.
| Environment Variable | Value | Purpose |
|---|---|---|
TEST_HOME | $(mktemp -d) | Temporary home directory |
HOME | $TEST_HOME | Override home for isolation |
XDG_CONFIG_HOME | $TEST_HOME/.config | XDG config location |
OPENCODE_CONFIG_DIR | $TEST_HOME/.config/opencode | OpenCode config override |
REPO_ROOT | $(cd ../.. && pwd) | Repository root path |
Sources: tests/opencode/setup.sh1-74
The setup script creates test skills in all three priority locations to enable comprehensive priority testing:
| Location | Skill Name | Marker | Purpose |
|---|---|---|---|
~/.config/opencode/superpowers/skills/ | (all skills from repo) | N/A | Base skill library |
~/.config/opencode/skills/personal-test/ | personal-test | PERSONAL_SKILL_MARKER_12345 | Personal skill verification |
$TEST_HOME/test-project/.opencode/skills/project-test/ | project-test | PROJECT_SKILL_MARKER_67890 | Project skill verification |
Sources: tests/opencode/setup.sh29-58
Unit tests validate core functionality without requiring OpenCode installation. They use Node.js directly to test JavaScript functions and bash commands to verify file structure.
Verifies plugin installation structure and basic integrity.
Test Coverage:
Sources: tests/opencode/test-plugin-loading.sh1-82
Tests the skills-core.js library functions directly via Node.js inline implementations. This approach avoids ESM path resolution issues in test environments while validating core algorithms.
Functions Tested:
extractFrontmatter Implementation Test
The test validates parsing of YAML frontmatter:
Expected result: {name: "test-skill", description: "A test skill for unit testing"}
Sources: tests/opencode/test-skills-core.sh17-84
stripFrontmatter Implementation Test
Validates removal of frontmatter while preserving content:
--- delimiters or YAML fieldsSources: tests/opencode/test-skills-core.sh86-132
findSkillsInDir Implementation Test
Creates test directory structure:
$TEST_HOME/skills-dir/
├── skill-a/SKILL.md
├── skill-b/SKILL.md
└── nested/
└── skill-c/SKILL.md
Validates recursive discovery with configurable maxDepth parameter. Expected: 3 skills found, including nested ones.
Sources: tests/opencode/test-skills-core.sh134-246
resolveSkillPath Priority Test
Tests resolution order and prefix handling:
| Query | Personal Exists | Superpowers Exists | Result |
|---|---|---|---|
shared-skill | ✓ | ✓ | Personal (shadowing) |
superpowers:shared-skill | ✓ | ✓ | Superpowers (forced) |
unique-skill | ✗ | ✓ | Superpowers (fallback) |
not-a-skill | ✗ | ✗ | null |
Sources: tests/opencode/test-skills-core.sh248-363
checkForUpdates Git Test
Validates graceful error handling for edge cases:
false (not error)falsefalseSources: tests/opencode/test-skills-core.sh365-437
Integration tests require OpenCode installation and validate end-to-end functionality using the opencode run command with 60-second timeouts.
Tests native skill tools: find_skills and use_skill.
Test Flow:
Test Cases:
| Test | Command | Expected Output | Validation |
|---|---|---|---|
| find_skills | opencode run "Use find_skills..." | superpowers:brainstorming, personal-test | grep patterns |
| use_skill (personal) | opencode run "Use use_skill personal-test" | PERSONAL_SKILL_MARKER_12345 | Marker presence |
| use_skill (prefix) | opencode run "Use use_skill superpowers:brainstorming" | brainstorming content | Skill loaded |
Sources: tests/opencode/test-tools.sh1-105
Validates three-tier skill priority system: project > personal > superpowers.
Test Setup:
Creates priority-test skill in all three locations with unique markers:
Priority Resolution Tests:
| Test | Working Directory | Skill Name | Expected Marker |
|---|---|---|---|
| Test 2: Personal > Superpowers | $HOME | priority-test | PRIORITY_MARKER_PERSONAL_VERSION |
| Test 3: Project > Personal | test-project/ | priority-test | PRIORITY_MARKER_PROJECT_VERSION |
| Test 4: Force superpowers | test-project/ | superpowers:priority-test | PRIORITY_MARKER_SUPERPOWERS_VERSION |
| Test 5: project: prefix | $HOME | project:priority-test | Error (not in project) |
Priority Override Mechanism:
Sources: tests/opencode/test-priority.sh1-199
The runner tracks and reports:
Example output:
========================================
Test Results Summary
========================================
Passed: 2
Failed: 0
Skipped: 2
Note: Integration tests were not run.
Use --integration flag to run tests that require OpenCode.
STATUS: PASSED
Sources: tests/opencode/run-tests.sh143-165
The test suite provides reusable helper functions via setup.sh:
Removes temporary test environment on exit:
Sources: tests/opencode/setup.sh65-72
Critical variables exported for test usage:
$TEST_HOME: Temporary test directory$REPO_ROOT: Repository root pathcleanup_test_env: Function for cleanupSources: tests/opencode/setup.sh72-73
The test suite validates the actual plugin code at .opencode/plugins/superpowers.js.
Plugin Functions vs Test Coverage:
| Function | Line Range | Tested By | Test Type |
|---|---|---|---|
extractAndStripFrontmatter | .opencode/plugins/superpowers.js16-34 | test-skills-core.sh (similar logic) | Unit |
normalizePath | .opencode/plugins/superpowers.js37-47 | Indirectly via setup validation | Unit |
getBootstrapContent | .opencode/plugins/superpowers.js56-84 | test-plugin-loading.sh (file existence) | Unit |
experimental.chat.system.transform | .opencode/plugins/superpowers.js88-94 | test-tools.sh (end-to-end) | Integration |
Sources: .opencode/plugins/superpowers.js1-96 tests/opencode/test-plugin-loading.sh1-82 tests/opencode/test-skills-core.sh1-441 tests/opencode/test-tools.sh1-105
Sources: tests/opencode/run-tests.sh1-166
To avoid ESM module resolution issues, test-skills-core.sh embeds function implementations directly in Node.js test commands:
This pattern enables testing without installing the plugin or dealing with module paths.
Sources: tests/opencode/test-skills-core.sh34-69
Test skills contain unique markers for verification:
PERSONAL_SKILL_MARKER_12345 in personal skillsPROJECT_SKILL_MARKER_67890 in project skillsPRIORITY_MARKER_*_VERSION in priority test skillsTests use grep to verify correct skill loading:
Sources: tests/opencode/setup.sh42 tests/opencode/test-tools.sh70 tests/opencode/test-priority.sh31-59
Integration tests use 60-second timeouts to prevent hanging:
Sources: tests/opencode/test-tools.sh29-36
Integration tests check for OpenCode availability and skip gracefully:
This allows the test suite to pass in CI/CD without OpenCode installed.
Sources: tests/opencode/test-tools.sh18-22 tests/opencode/test-priority.sh90-97
Refresh this wiki
This wiki was recently refreshed. Please wait 3 days to refresh again.