Skip to content

Conversation

@eablack
Copy link
Contributor

@eablack eablack commented Jan 5, 2026

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 1 of 11 in the incremental migration plan.

Summary

Migrates 11 test files in the Auth & Sessions category to be compatible with @oclif/test v4.1.15, including tests for authentication,
OAuth authorizations, and session management. This PR establishes the migration patterns used across all subsequent PRs.

Files Migrated (11 total)

  • test/unit/commands/auth/token.unit.test.ts (1 test)
  • test/unit/commands/auth/whoami.unit.test.ts (1 test)
  • test/unit/commands/authorizations/create.unit.test.ts (2 tests)
  • test/unit/commands/authorizations/index.unit.test.ts (2 tests)
  • test/unit/commands/authorizations/info.unit.test.ts (2 tests)
  • test/unit/commands/authorizations/revoke.unit.test.ts (2 tests)
  • test/unit/commands/authorizations/rotate.unit.test.ts (1 test)
  • test/unit/commands/authorizations/update.unit.test.ts (3 tests)
  • test/unit/commands/sessions/destroy.unit.test.ts (2 tests)
  • test/unit/commands/sessions/index.unit.test.ts (2 tests)
  • test/unit/lib/authorizations/authorizations.unit.test.ts (7 tests)

Total: 25 tests migrated ✅

Migration Changes

All tests were updated to use the new @oclif/test v4 API:

Before (v2):
test
.stdout()
.nock('https://api.heroku.com', api => {
api.get('/oauth/authorizations/f6e8d969-129f-42d2-854b-c2eca9d5a42e')
.reply(200, authorization)
})
.command(['authorizations:info', 'f6e8d969-129f-42d2-854b-c2eca9d5a42e'])
.it('shows authorization info', ctx => {
expect(ctx.stdout).to.contain('[email protected]')
})

After (v4):
it('shows authorization info', async () => {
nock('https://api.heroku.com')
.get('/oauth/authorizations/f6e8d969-129f-42d2-854b-c2eca9d5a42e')
.reply(200, authorization)

const {stdout} = await runCommand(['authorizations:info', 'f6e8d969-129f-42d2-854b-c2eca9d5a42e'])

expect(stdout).to.contain('[email protected]')

})

Key Pattern Changes

  1. API: Replaced chaining test API with runCommand() function
  2. Async: Converted callback-style tests to async/await
  3. Context: Destructured {stdout, stderr, error} from result instead of ctx parameter
  4. Error Handling: Check error property in result object instead of .catch() chaining
  5. Cleanup: Added afterEach(() => nock.cleanAll()) hooks
  6. Nock Setup: Moved nock setup inside each test for better isolation

Testing

  • ✅ All 25 migrated tests pass locally
  • ✅ Tests pass in CI
  • ✅ No regressions in other test suites
  • ✅ Build passes

Notes

This PR establishes the migration patterns and approach that will be used across all subsequent PRs in the migration plan. The patterns
have been validated to work with core authentication functionality.

Related

  • Part of the @oclif/test v2 → v4 migration plan outlined in OCLIF_TEST_UPGRADE_PR_PLAN.md
  • Follows foundation PR -- test: upgrade @oclif/test to v4 #3447 -- that upgrades the package version

@eablack eablack force-pushed the eb/upgrade-oclif-test-auth branch from 335bd19 to adc81ea Compare January 5, 2026 23:35
eablack added 11 commits January 5, 2026 17:14
- Convert from v2 chaining API to v4 runCommand API
- Use async/await pattern
- Import expect from chai directly
- All 3 tests passing
- Convert from v2 chaining API to v4 runCommand API
- Handle error exit code with error?.oclif?.exit
- All 2 tests passing
- Convert from v2 chaining API to v4 runCommand API
- All 3 tests passing
- Convert from v2 chaining API to v4 runCommand API
- All 3 tests passing
- Convert from v2 chaining API to v4 runCommand API
- All 3 tests passing
- Convert from v2 chaining API to v4 runCommand API
- All 2 tests passing
- Convert from v2 chaining API to v4 runCommand API
- All 1 tests passing
- Convert from v2 chaining API to v4 runCommand API
- All 1 tests passing
- Convert from v2 chaining API to v4 runCommand API
- All 1 tests passing
- Convert from v2 chaining API to v4 runCommand API
- All 3 tests passing
- Convert from v2 chaining API to v4 captureOutput API
- All 3 tests passing
@eablack eablack force-pushed the eb/upgrade-oclif-test-auth branch from 9fc744c to 8c22192 Compare January 6, 2026 01:14
@eablack eablack temporarily deployed to AcceptanceTests January 6, 2026 01:14 — with GitHub Actions Inactive
@eablack eablack temporarily deployed to AcceptanceTests January 6, 2026 01:14 — with GitHub Actions Inactive
@eablack eablack temporarily deployed to AcceptanceTests January 6, 2026 01:14 — with GitHub Actions Inactive
@eablack eablack temporarily deployed to AcceptanceTests January 6, 2026 01:14 — with GitHub Actions Inactive
@eablack eablack temporarily deployed to AcceptanceTests January 6, 2026 01:22 — with GitHub Actions Inactive
@eablack eablack temporarily deployed to AcceptanceTests January 6, 2026 01:22 — with GitHub Actions Inactive
@eablack eablack temporarily deployed to AcceptanceTests January 6, 2026 01:22 — with GitHub Actions Inactive
@eablack eablack temporarily deployed to AcceptanceTests January 6, 2026 01:22 — with GitHub Actions Inactive
@eablack eablack mentioned this pull request Jan 6, 2026
12 tasks
@eablack eablack changed the title chore: convert auth to oclif/test 4 test: convert auth to oclif/test 4 Jan 6, 2026
@eablack eablack changed the title test: convert auth to oclif/test 4 test: migrate Auth & Sessions tests to @oclif/test v4 Jan 6, 2026
@eablack eablack marked this pull request as ready for review January 7, 2026 22:54
@eablack eablack requested a review from a team as a code owner January 7, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant