test: migrate Apps Core tests to @oclif/test v4 (PR 8/11) #3458
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.
This PR is part of a series migrating test files from @oclif/test v2 to v4 following the package upgrade in the foundation PR. This is PR 8 of 11 in the incremental migration plan.
Description
Migrates 15 test files in the Apps Core category to be compatible with @oclif/test v4.1.15, including tests for app lifecycle management (create, destroy, info, rename, open), app organization (favorites, errors), stack management, rake command, and confirmation dialogs.
Files Migrated (15 total)
test/unit/commands/apps/create.unit.test.ts(11 tests)test/unit/commands/apps/destroy.unit.test.ts(3 tests)test/unit/commands/apps/errors.unit.test.ts(5 tests)test/unit/commands/apps/favorites/add.unit.test.ts(3 tests)test/unit/commands/apps/favorites/index.unit.test.ts(2 tests)test/unit/commands/apps/favorites/remove.unit.test.ts(2 tests)test/unit/commands/apps/index.unit.test.ts(16 tests)test/unit/commands/apps/info.unit.test.ts(12 tests)test/unit/commands/apps/leave.unit.test.ts(3 tests)test/unit/commands/apps/open.unit.test.ts(2 tests)test/unit/commands/apps/rename.unit.test.ts(2 tests)test/unit/commands/apps/stacks/index.unit.test.ts(2 tests)test/unit/commands/apps/stacks/set.unit.test.ts(3 tests)test/unit/commands/rake.unit.test.ts(3 tests)test/unit/lib/confirm-command.unit.test.ts(5 tests)Total: 74 tests migrated ✅
Migration Changes
All tests were updated to use the new @oclif/test v4 API:
Before (v2):
After (v4):
Key Pattern Changes
runCommand()function{stdout, stderr, error}from result instead ofctxparameterafterEach(() => nock.cleanAll())hooks for nock testserrorobject from return value for expected errors instead of.catch()runCommandHelperfor tests with sinon stubs (create with manifest, open, rake, confirm-command)Special Cases
Tests with Sinon Stubs
Some tests required the custom
runCommandHelperinstead of @oclif/test v4'srunCommandbecause they use sinon stubs:Addon Parsing Issue
The
apps/createaddon tests initially failed with @oclif/test v4'srunCommand- comma-separated addons weren't parsed correctly. UsingrunCommandHelperresolved this issue.Error Handling Pattern
For tests expecting errors:
Before (v2):
After (v4):
Testing
✅ All 74 migrated tests pass locally
✅ No regressions in other test suites
✅ Build passes
Test Results:
Related