test: migrate CI and Certificate tests to @oclif/test v4 (PR 6/11)#3455
Merged
eablack merged 14 commits intoeb/upgrade-oclif-testfrom Jan 12, 2026
Merged
test: migrate CI and Certificate tests to @oclif/test v4 (PR 6/11)#3455eablack merged 14 commits intoeb/upgrade-oclif-testfrom
eablack merged 14 commits intoeb/upgrade-oclif-testfrom
Conversation
13 tasks
michaelmalave
approved these changes
Jan 9, 2026
Contributor
michaelmalave
left a comment
There was a problem hiding this comment.
Changes look good and complete for ci and certificate!
Convert from chained test API to async/await with runCommand().
Convert from chained test API to async/await with runCommand().
Convert from chained test API to async/await with runCommand().
Convert from chained test API to async/await with runCommand().
Convert from chained test API to async/await with runCommand(). Use custom runCommand helper for test with sinon stub.
Convert from chained test API to async/await with runCommand(). Handle exit code testing with error.oclif.exit property.
Convert from chained test API to async/await with runCommand().
Convert from chained test API to async/await with runCommand(). Replace .do() with direct async setup before runCommand().
Add GitService class in git.ts and FileService class in source.ts to wrap ES module functions, enabling proper stubbing in tests. test: migrate ci:rerun to @oclif/test v4 Convert from chained test API to async/await with customRunCommand(). Use GitService and FileService stubs instead of trying to stub ES modules directly.
Add readCommit method to GitService class for consistency. Update ci:run command to use GitService instance instead of direct imports. test: migrate ci:run to @oclif/test v4 Convert from chained test API to async/await with customRunCommand(). Use GitService and FileService stubs for ES module dependencies.
- Convert from chained API to async/await with runCommand() - Replace .nock().command().it() with async setup + await runCommand() - Update expect() to use chai instead of @oclif/test - Fix test isolation by adding nock.cleanAll() before test-specific mocks - All 9 tests passing
- Update imports to use chai instead of @oclif/test - Already using runCommand() helper and async/await pattern - All 10 tests passing
The issue was that src/commands/ci/run.ts was creating its own gitService instance, while tests were stubbing the gitService instance from source.ts. This caused the stubs to not affect the actual command execution. Solution: - Export a shared gitService instance from src/lib/ci/git.ts - Update both run.ts and source.ts to import the shared instance - Update tests to import gitService from git.ts directly This ensures tests stub the same instance used by the commands.
eb2ad55 to
2f304e1
Compare
eablack
added a commit
that referenced
this pull request
Jan 13, 2026
…3455) * test: migrate ci:config:get to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci:config to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci:config:set to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci:config:unset to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci to @oclif/test v4 Convert from chained test API to async/await with runCommand(). Use custom runCommand helper for test with sinon stub. * test: migrate ci:info to @oclif/test v4 Convert from chained test API to async/await with runCommand(). Handle exit code testing with error.oclif.exit property. * test: migrate ci:last to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci:migrate-manifest to @oclif/test v4 Convert from chained test API to async/await with runCommand(). Replace .do() with direct async setup before runCommand(). * feat: add GitService and FileService wrappers for testing Add GitService class in git.ts and FileService class in source.ts to wrap ES module functions, enabling proper stubbing in tests. test: migrate ci:rerun to @oclif/test v4 Convert from chained test API to async/await with customRunCommand(). Use GitService and FileService stubs instead of trying to stub ES modules directly. * feat: add readCommit to GitService and update ci:run command Add readCommit method to GitService class for consistency. Update ci:run command to use GitService instance instead of direct imports. test: migrate ci:run to @oclif/test v4 Convert from chained test API to async/await with customRunCommand(). Use GitService and FileService stubs for ES module dependencies. * test: migrate certs/generate to @oclif/test v4 - Convert from chained API to async/await with runCommand() - Replace .nock().command().it() with async setup + await runCommand() - Update expect() to use chai instead of @oclif/test - Fix test isolation by adding nock.cleanAll() before test-specific mocks - All 9 tests passing * test: migrate certs/add to @oclif/test v4 - Update imports to use chai instead of @oclif/test - Already using runCommand() helper and async/await pattern - All 10 tests passing * fix: export shared gitService instance to fix test stubbing The issue was that src/commands/ci/run.ts was creating its own gitService instance, while tests were stubbing the gitService instance from source.ts. This caused the stubs to not affect the actual command execution. Solution: - Export a shared gitService instance from src/lib/ci/git.ts - Update both run.ts and source.ts to import the shared instance - Update tests to import gitService from git.ts directly This ensures tests stub the same instance used by the commands. * update with test conventions
eablack
added a commit
that referenced
this pull request
Jan 13, 2026
* Comment out oclif/test tests and upgrade to oclif/test to 4.x * chore: properly install @oclif/test@4.1.15 * fix: update test imports for @oclif/test v4 compatibility - Replace @oclif/test expect imports with chai - Remove FancyTypes dependency in test helpers - Add @ts-nocheck to unmigrated test files - Fixes TypeScript compilation errors * test: migrate Auth & Sessions tests to @oclif/test v4 (#3446) * test: migrate auth/token to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - Use async/await pattern - Import expect from chai directly - All 3 tests passing * test: migrate auth/whoami to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - Handle error exit code with error?.oclif?.exit - All 2 tests passing * test: migrate authorizations/create to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - All 3 tests passing * test: migrate authorizations/index to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - All 3 tests passing * test: migrate authorizations/info to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - All 3 tests passing * test: migrate revoke.unit.test.ts to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - All 2 tests passing * test: migrate rotate.unit.test.ts to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - All 1 tests passing * test: migrate update.unit.test.ts to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - All 1 tests passing * test: migrate destroy.unit.test.ts to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - All 1 tests passing * test: migrate index.unit.test.ts to @oclif/test v4 - Convert from v2 chaining API to v4 runCommand API - All 3 tests passing * test: migrate authorizations.unit.test.ts to @oclif/test v4 - Convert from v2 chaining API to v4 captureOutput API - All 3 tests passing * fix trailing whitespace * update and apply test conventions with beforeeach/aftereach * update convention for rotate test * test: migrate 2fa, Keys, Members tests to @oclif/test v4 (#3448) * test: migrate 2fa/index to @oclif/test v4 * test: migrate keys/add to @oclif/test v4 * test: migrate keys/clear to @oclif/test v4 * test: migrate keys/index and keys/remove to @oclif/test v4 * test: migrate members/add to @oclif/test v4 * test: migrate members/index to @oclif/test v4 * test: migrate members/remove to @oclif/test v4 * test: migrate members/set to @oclif/test v4 * test: migrate notifications/index to @oclif/test v4 * test: migrate status to @oclif/test v4 * apply testing conventions and resolve linting issues * test: convert Config and Features/Labs to oclif/test 4 (#3449) * test: migrate config/get to @oclif/test v4 * test: migrate config/index to @oclif/test v4 * test: migrate config/set to @oclif/test v4 * test: migrate config/unset to @oclif/test v4 * test: migrate features/disable to @oclif/test v4 * test: migrate features/enable to @oclif/test v4 * test: migrate features/index to @oclif/test v4 * test: migrate features/info to @oclif/test v4 * test: migrate labs/disable to @oclif/test v4 * test: migrate labs/enable to @oclif/test v4 * test: migrate labs/index to @oclif/test v4 * test: migrate config/edit to @oclif/test v4 Migrates config/edit.unit.test.ts from @oclif/test v2 to v4, completing the last test file in the Configuration tests migration. Key changes: - Add EditorFactory class with instance method to enable testability - Update config/edit command to use EditorFactory pattern - Migrate tests to use custom runCommand helper with sinon stubs - All 4 tests passing (stringToConfig, deleting vars, blanks, specific var) Uses custom runCommand helper (not @oclif/test's runCommand) because @oclif/core's dynamic module loading is incompatible with ES module mocking via sinon or esmock. * apply testing conventions * test: migrate autocomplete, drains, git, local, maintenance tests to @oclif/test v4 (PR #5) (#3454) * test: migrate autocomplete/index to @oclif/test v4 Migrated 2 tests from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted all tests to async/await pattern - Kept runtest wrapper for Windows platform checking * test: migrate autocomplete/script to @oclif/test v4 Migrated 3 tests from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Converted all tests to async/await pattern - Used getConfig() helper to access config.cacheDir for exact assertions - Kept runtest wrapper for Windows platform checking * test: migrate drains/add to @oclif/test v4 * test: migrate drains/index to @oclif/test v4 * test: migrate drains/remove to @oclif/test v4 * test: migrate git/clone to @oclif/test v4 * test: migrate git/credentials to @oclif/test v4 * test: migrate git/remote to @oclif/test v4 * test: migrate local/version to @oclif/test v4 * test: migrate local/run to @oclif/test v4 * test: migrate maintenance/index to @oclif/test v4 * test: migrate maintenance/off to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate maintenance/on to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate local/index to @oclif/test v4 Convert from chained test API to async/await with runCommand(). Migrated 17 tests covering flag validation, error handling, argument construction, procfile integration, and environment file integration. * apply testing conventions, fix linting * apply conventions to drains remove * test: migrate CI and Certificate tests to @oclif/test v4 (PR 6/11) (#3455) * test: migrate ci:config:get to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci:config to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci:config:set to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci:config:unset to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci to @oclif/test v4 Convert from chained test API to async/await with runCommand(). Use custom runCommand helper for test with sinon stub. * test: migrate ci:info to @oclif/test v4 Convert from chained test API to async/await with runCommand(). Handle exit code testing with error.oclif.exit property. * test: migrate ci:last to @oclif/test v4 Convert from chained test API to async/await with runCommand(). * test: migrate ci:migrate-manifest to @oclif/test v4 Convert from chained test API to async/await with runCommand(). Replace .do() with direct async setup before runCommand(). * feat: add GitService and FileService wrappers for testing Add GitService class in git.ts and FileService class in source.ts to wrap ES module functions, enabling proper stubbing in tests. test: migrate ci:rerun to @oclif/test v4 Convert from chained test API to async/await with customRunCommand(). Use GitService and FileService stubs instead of trying to stub ES modules directly. * feat: add readCommit to GitService and update ci:run command Add readCommit method to GitService class for consistency. Update ci:run command to use GitService instance instead of direct imports. test: migrate ci:run to @oclif/test v4 Convert from chained test API to async/await with customRunCommand(). Use GitService and FileService stubs for ES module dependencies. * test: migrate certs/generate to @oclif/test v4 - Convert from chained API to async/await with runCommand() - Replace .nock().command().it() with async setup + await runCommand() - Update expect() to use chai instead of @oclif/test - Fix test isolation by adding nock.cleanAll() before test-specific mocks - All 9 tests passing * test: migrate certs/add to @oclif/test v4 - Update imports to use chai instead of @oclif/test - Already using runCommand() helper and async/await pattern - All 10 tests passing * fix: export shared gitService instance to fix test stubbing The issue was that src/commands/ci/run.ts was creating its own gitService instance, while tests were stubbing the gitService instance from source.ts. This caused the stubs to not affect the actual command execution. Solution: - Export a shared gitService instance from src/lib/ci/git.ts - Update both run.ts and source.ts to import the shared instance - Update tests to import gitService from git.ts directly This ensures tests stub the same instance used by the commands. * update with test conventions * test: convert Buildpacks and Domains to @oclif/test v4 (#3452) * test: migrate buildpacks/add to @oclif/test v4 * test: migrate buildpacks/clear to @oclif/test v4 * test: migrate buildpacks/index to @oclif/test v4 Migrated 11 tests from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted all tests to async/await pattern - Updated test expectations to match actual command output (removed ⬢ symbol) * test: migrate buildpacks/info to @oclif/test v4 Migrated 3 tests from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted all tests to async/await pattern - Updated error handling tests to use error property from runCommand result * test: migrate buildpacks/remove to @oclif/test v4 Migrated 18 tests from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted all tests to async/await pattern - Updated error handling tests to use error property from runCommand result - Organized tests in 3 describe blocks: -i INDEX, URL, and -i INDEX URL * test: migrate buildpacks/search to @oclif/test v4 Migrated 2 tests from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted all tests to async/await pattern * test: migrate buildpacks/set to @oclif/test v4 Migrated 13 tests from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted all tests to async/await pattern - Updated error handling tests to use error property from runCommand result - Organized tests in 2 describe blocks: URL and -i INDEX URL * test: migrate buildpacks/versions to @oclif/test v4 Migrated 3 tests from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added beforeEach/afterEach hooks for environment variable setup and nock cleanup - Converted all tests to async/await pattern - Replaced .env() with process.env manipulation in beforeEach/afterEach - Updated error handling tests to use error property from runCommand result * test: migrate domains/clear to @oclif/test v4 Migrated 1 test from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted test to async/await pattern * test: migrate domains/remove to @oclif/test v4 Migrated 1 test from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted test to async/await pattern * test: migrate domains/info to @oclif/test v4 Migrated 1 test from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted test to async/await pattern * test: migrate domains/update to @oclif/test v4 Migrated 1 test from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted test to async/await pattern * test: migrate domains/wait to @oclif/test v4 Migrated 2 tests from @oclif/test v2 to v4: - Changed imports to use runCommand from @oclif/test and expect from chai - Added afterEach hook for nock cleanup - Converted all tests to async/await pattern * test: migrate domains/add to @oclif/test v4 Migrated 2 tests from @oclif/test v2 to v4: - Changed to use custom runCommand helper from test/helpers/runCommand.ts - This allows sinon stubs to work with ESM modules - Added imports for stdout/stderr from stdout-stderr package - Converted all tests to async/await pattern - Kept sinon stubs for promptForCert method * test: migrate domains/index to @oclif/test v4 Migrated 4 tests from @oclif/test v2 to v4: - Changed to use custom runCommand helper from test/helpers/runCommand.ts - This allows sinon stubs to work with ESM modules - Added imports for stdout/stderr from stdout-stderr package - Converted all tests to async/await pattern - Kept sinon stub for confirmDisplayAllDomains method - Added helpers: unwrap and removeAllWhitespace * update with test conventions * fix spacing * test: migrate Clients & Misc tests to @oclif/test v4 (PR #7) (#3457) * test: migrate clients/create to @oclif/test v4 * test: migrate clients/destroy to @oclif/test v4 * test: migrate clients/index to @oclif/test v4 * test: migrate clients/info to @oclif/test v4 * test: migrate clients/rotate to @oclif/test v4 * test: migrate clients/update to @oclif/test v4 * test: migrate labs/info to @oclif/test v4 * test: migrate regions to @oclif/test v4 * test: migrate lib/clients/clients to @oclif/test v4 * apply testing conventions * test: migrate Apps Core tests to @oclif/test v4 (PR 8/11) (#3458) * test: migrate apps/create to @oclif/test v4 - 11 tests migrated - Uses custom runCommand helper for tests with sinon stubs (manifest flag) - Uses custom runCommand helper for addon tests to avoid parsing issues with @oclif/test v4 * test: migrate apps/destroy to @oclif/test v4 * test: migrate apps/errors to @oclif/test v4 * test: migrate apps/favorites/add to @oclif/test v4 * test: migrate apps/favorites tests to @oclif/test v4 - apps/favorites/add (3 tests) - apps/favorites/index (2 tests) - apps/favorites/remove (2 tests) * test: migrate apps/rename to @oclif/test v4 * test: migrate apps/open and apps/leave to @oclif/test v4 - apps/open uses custom runCommand for sinon stubs (2 tests) - apps/leave uses custom runCommand (3 tests) * test: migrate apps/stacks tests to @oclif/test v4 * test: migrate rake and lib/confirm-command to @oclif/test v4 * test: migrate apps/index to @oclif/test v4 * test: migrate apps/info to @oclif/test v4 * fix tests * apply testing conventions * test: migrate remaining tests to @oclif/test v4 (PR #11) (#3461) * test: migrate ps/disable to @oclif/test v4 * test: migrate ps/enable to @oclif/test v4 * test: migrate ps/wait to @oclif/test v4 * test: migrate reviewapps/disable to @oclif/test v4 * test: migrate reviewapps/enable to @oclif/test v4 * test: migrate spaces/drains/set to @oclif/test v4 * test: migrate spaces/peerings/accept to @oclif/test v4 * test: migrate spaces/ps to @oclif/test v4 * test: migrate spaces/transfer to @oclif/test v4 * test: migrate spaces/trusted-ips/add to @oclif/test v4 * test: migrate spaces/trusted-ips/index to @oclif/test v4 * test: migrate spaces/trusted-ips/remove to @oclif/test v4 * test: migrate lib/webhooks/base to @oclif/test v4 * test: migrate utils/keyValueParser to @oclif/test v4 * test: migrate utils/paginator to @oclif/test v4 * test: migrate integration/run to @oclif/test v4 * apply testing conventions * test: migrate Pipelines Part 1 tests to @oclif/test v4 (PR 9/11) (#3459) * test: migrate pipelines/create to @oclif/test v4 * test: migrate pipelines/destroy to @oclif/test v4 * test: migrate pipelines/index to @oclif/test v4 * test: migrate pipelines/info to @oclif/test v4 * test: migrate pipelines/open to @oclif/test v4 * test: migrate pipelines/remove to @oclif/test v4 * test: migrate pipelines/rename to @oclif/test v4 * apply testing conventions * test: migrate pipelines tests (Part 2 of 2) to @oclif/test v4 (#3460) * test: migrate pipelines/add to @oclif/test v4 * test: migrate pipelines/connect to @oclif/test v4 * test: migrate pipelines/diff to @oclif/test v4 * test: migrate pipelines/promote to @oclif/test v4 * test: migrate pipelines/update to @oclif/test v4 * fix: correct test name 'can promote by app id' * test: migrate pipelines/transfer to @oclif/test v4 * test: migrate pipelines/setup to @oclif/test v4 * apply testing conventions * set up nock for github * test: upgrade commented out oclif tests to @oclif/test v4 (#3465) * convert 2fa and logout tests * convert and skip commented out old oclf/test tests * convert console test
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.
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 6 of 11 in the incremental migration plan.
Description
Migrates 12 test files in the CI Commands and Certificates category to be compatible with @oclif/test v4.1.15, including tests for CI configuration, CI test runs, and SSL certificate management.
Files Migrated (12 total)
CI Config Tests (4 files):
CI Command Tests (6 files):
Certificate Tests (2 files):
Total: 56 tests migrated ✅
Migration Changes
All tests were updated to use the new @oclif/test v4 API:
Before (v2):
After (v4):
Key Pattern Changes
runCommand()functionstdout.outputandstderr.outputfromstdout-stderrpackageerror?.oclif?.exitproperty for exit codesafterEach(() => nock.cleanAll())hooksSpecial Changes
ES Module Stubbing Solution
For tests requiring stubs of ES module exports (which Sinon cannot stub directly), we implemented a service wrapper pattern:
Created wrapper classes in source files:
GitServiceinsrc/lib/ci/git.ts- wraps git operationsFileServiceinsrc/lib/ci/source.ts- wraps file operationsUpdated source code to use service instances:
Tests now stub service methods:
Test Isolation Fix
Fixed test isolation issue in
certs/generate.unit.test.tswhere a test-specific nock mock was being overridden by thebeforeEachmock. Addednock.cleanAll()before setting up test-specific mocks to ensure proper isolation.Testing
Related
OCLIF_TEST_UPGRADE_PR_PLAN.md