/nushell-dev:test [action] [target] [--coverage]from nushell-dev
Create or run tests for Nushell code
Ships in nushell-dev. Installing the plugin adds it to Claude Code.
Create or run tests for Nushell code.
Arguments:
Actions:
If $1 is "create":
Read the target source file: @$2
Analyze exported functions and their signatures
Generate test file with:
Create test file at tests/test_[module-name].nu:
# tests/test_utils.nu - Generated tests for utils.nu
use ../src/utils.nu
# Assertion helpers
def assert-eq [expected: any, actual: any, message?: string] {
if $expected != $actual {
error make { msg: ($message | default $"Expected ($expected), got ($actual)") }
}
}
def assert [condition: bool, message?: string] {
if not $condition {
error make { msg: ($message | default "Assertion failed") }
}
}
# Tests for each exported function
def "test function-name" [] {
# TODO: Add test cases
let result = function-name args
assert-eq expected $result "function-name should return expected"
}
# Test runner
def "test all" [] {
test function-name
# Add more tests...
print "✅ All tests passed"
}
If $1 is "run":
Find test files:
Execute each test file:
!nu $test_file
Collect results and report:
Running tests...
✅ tests/test_utils.nu - 5 passed
❌ tests/test_api.nu - 3 passed, 1 failed
- test fetch-data: Expected 200, got 404
Summary: 8 passed, 1 failed
If --coverage: analyze which functions were tested
If $1 is "watch":
Explain that continuous testing requires external tools like:
watchexec -e nu -- nu tests/test_all.nuProvide a simple watcher script if requested.
Test patterns:
Reference the nushell-tooling skill for testing patterns: ${CLAUDE_PLUGIN_ROOT}/skills/nushell-tooling/SKILL.md
Generated test structure:
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub danielbodnar/nushell-dev --plugin nushell-dev7 commands in this plugin
/cli-checkCli CheckAudit a Nushell script against CLI guidelines from clig.dev/cli-scaffoldCli ScaffoldCreate a new CLI-compliant Nushell script from template/convertShell (bash/sh/zsh) Conversions:Convert code from other languages to Nushell/docsGenerate documentation from Nushell code/lintLint Nushell code and suggest fixes/newScaffold new Nushell script, module, command, overlay, plugin, test, or configOther plugins' commands for the same job