test: migrate Auth & Sessions tests to @oclif/test v4#3446
test: migrate Auth & Sessions tests to @oclif/test v4#3446eablack merged 14 commits intoeb/upgrade-oclif-testfrom
Conversation
335bd19 to
adc81ea
Compare
- Convert from v2 chaining API to v4 captureOutput API - All 3 tests passing
9fc744c to
8c22192
Compare
k80bowman
left a comment
There was a problem hiding this comment.
This looks great, I really like the new test format. Just one suggestion, but it's not blocking. I've been defining the nock scope in a beforeEach and then using nock's done() function (along with cleanAll()) in an afterEach to ensure that nock is handling all the calls it's supposed to as part of the tests. There's an example in the applink repo, if that's something you'd be interested in adding.
agree, that looks like a good convention to apply. updated with that structure! |
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)
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('test@heroku.com')
})
After (v4):
it('shows authorization info', async () => {
nock('https://api.heroku.com')
.get('/oauth/authorizations/f6e8d969-129f-42d2-854b-c2eca9d5a42e')
.reply(200, authorization)
})
Key Pattern Changes
Testing
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