test(cli): add Jest test suite for PromptKit CLI#148
Closed
Conversation
Add comprehensive test coverage for the CLI module: - manifest.js: loadManifest, getTemplates, persona/protocol/format/ taxonomy lookups, resolveTemplateDeps (16 tests) - assemble.js: stripFrontmatter, loadComponent, full assembly with section ordering, param substitution, verbatim inclusion (15 tests) - launch.js: detectCli priority order with mocked child_process, copyContentToTemp file/directory operations (9 tests) - cli.js: integration tests for list, assemble, --version, error handling via subprocess execution (7 tests) Tests validate against real repo content (personas/, protocols/, formats/, templates/, manifest.yaml) rather than synthetic fixtures, so they catch structural regressions without maintenance burden. Infrastructure: - Jest dev dependency with test and test:coverage scripts - CI workflow (.github/workflows/cli-tests.yml) triggers on cli/ changes - coverage/ added to .gitignore Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fe3aea9 to
f218c21
Compare
Collaborator
Author
|
Abandoning in favor of generating test cases from newly added validation.md in #145 |
Collaborator
Author
Suggestion: Use data-driven tests instead of hardcoded component namesThe tests currently hardcode specific component names ( Recommended approachIterate over the manifest dynamically so tests automatically cover every component with zero updates needed when the library evolves: Before (brittle): test("finds persona by name", () => {
const persona = getPersona(manifest, "systems-engineer");
expect(persona).toBeDefined();
expect(persona.path).toBe("personas/systems-engineer.md");
});After (data-driven): for (const p of manifest.personas) {
test("persona '\' resolves to an existing file", () => {
const found = getPersona(manifest, p.name);
expect(found).toBeDefined();
expect(fs.existsSync(path.join(repoRoot, found.path))).toBe(true);
});
}This pattern applies across all test files:
Additional gap
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #147
Adds comprehensive automated test coverage for the PromptKit CLI module.
What's included
53 tests across 4 suites — all passing:
manifest.test.jsassemble.test.jslaunch.test.jscli.test.jsInfrastructure
npm testandnpm run test:coveragecli/__tests__/fixtures/— minimal mock persona, protocols, format, taxonomy, templates, and manifest.github/workflows/cli-tests.yml) — runs on push/PR whencli/changescoverage/added to.gitignoreHow to run