Test this CyanPrint plugin. Use when the user asks to write plugin tests, add test cases, update snapshots, or debug plugin test failures. Covers test.cyan.yaml format with input directories, config, validate commands, and expected output.
Resources
1Install
npx skillscat add atomicloud/ketone-new-cyanprint/testing-plugin Install via the SkillsCat registry.
Testing this Plugin
Step 1: Understand what to test
Read the entry point code (cyan/index.ts or equivalent) to find:
- What
input.configkeys the plugin reads (e.g.,config.requireReadme,config.forbiddenPatterns) - What the plugin does (validation, transformation, or both)
- What files it reads or checks
Step 2: Prepare input files (if needed)
If the plugin needs input files to operate on, create an input directory:
inputs/
└── with-readme/
├── README.md
└── package.jsonStep 3: Write test.cyan.yaml
Create a test.cyan.yaml file in the plugin root:
tests:
- name: 'validation-passes'
expected:
type: snapshot
value:
path: ./snapshots/validation-passes
input: ./inputs/with-readme
config:
requireReadme: true
requireLicense: false
validate:
- test -f README.mdinput
Path to a directory containing input files the plugin receives. Omit if the plugin works on an empty directory.
input: ./inputs/with-readmeconfig
Keys must match the input.config keys your plugin actually reads. Extract them from the entry point code — do NOT invent fictional config keys.
expected
Declares expected output using a snapshot path:
expected:
type: snapshot
value:
path: ./snapshots/validation-passesvalidate
Optional plain shell commands to run after plugin execution:
validate:
- test -f src/index.ts
- test $(wc -c < output.bin) -eq 16Step 4: Run and iterate
# Run all plugin tests
cyanprint test plugin .
# Update snapshots after intentional changes
cyanprint test plugin . --update-snapshotsIf tests fail, check that your config keys match the actual config keys used in the entry point code.
See reference.md for complete examples.