feat(@inquirerer/test): add createTestFixture for CLI testing #45
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.
Summary
Adds a new
createTestFixture()function to@inquirerer/testthat provides a complete test harness for testing inquirerer-based CLI applications. This consolidates the duplicatedTestFixtureclass pattern found in bothpackages/cliandpgpm/cliin the constructive repo.The fixture handles:
createTestEnvironment()Inquirererprompter with the mock streams internallyUsage:
Review & Testing Checklist for Human
fixture.ts- The test suite passes with--passWithNoTests. Consider whether tests should be added before merging, or if integration testing via constructive is sufficient.commandsfunction signature matches constructive's CLIs - The expected signature is(argv: Partial<ParsedArgs>, prompter: Inquirerer, options: CLIOptions) => Promise<TResult>. Check that bothpackages/cliandpgpm/clicommands match this.TestEnvironmentis created once when the fixture is instantiated. IfrunCmdis called multiple times,writeResults/transformResultswill accumulate. Verify this is the intended behavior.Test plan: After publishing this package, update constructive to use
createTestFixtureand verify existing tests still pass.Notes
This is part of an ongoing effort to de-duplicate CLI test utilities between constructive's packages. A follow-up PR will update constructive to use this new fixture.
Link to Devin run: https://app.devin.ai/sessions/e5018850caff45ce8a126331548d69bc
Requested by: Dan Lynch (@pyramation)