Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(openapi/validate): rewrite tests to be more comprehensive #1188

Merged
merged 3 commits into from
Mar 5, 2025

Conversation

kanadgupta
Copy link
Member

🧰 Changes

rewrites our tests for openapi validate to be more compliant with our contributing guidelines. i initially wrote them this way to minimize the amount of legwork to get oclif working but this approach to testing is far more comprehensive and it should be much easier to drop in stray console logs for debugging purposes.

🧬 QA & Testing

do tests still pass?

@kanadgupta kanadgupta added refactor Issues about tackling technical debt command:openapi Issues pertaining to the `openapi`, `validate`, `reduce`, or `swagger` commands labels Mar 5, 2025
@kanadgupta kanadgupta requested review from erunion and emilyskuo March 5, 2025 19:36
@kanadgupta kanadgupta marked this pull request as ready for review March 5, 2025 19:36
});

beforeEach(() => {
consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we were previously handrolling mocks for console.info in addition to the console output mocking we get via @oclif/test. what a mess

@@ -148,22 +121,15 @@ describe('rdme openapi validate', () => {
});

it('should create GHA workflow if user passes in spec via prompts', async () => {
expect.assertions(6);
expect.assertions(3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we bother with expect.assertions at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i went back and forth here, they do seem unnecessary. i'll remove 'em

Copy link
Member

@emilyskuo emilyskuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@kanadgupta kanadgupta merged commit 96fe620 into next Mar 5, 2025
8 checks passed
@kanadgupta kanadgupta deleted the kanad-2025-03-05/validate-test-rewrite branch March 5, 2025 19:58
@kanadgupta
Copy link
Member Author

🎉 This PR is included in version 10.2.0-next.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

kanadgupta added a commit that referenced this pull request Mar 5, 2025
## 🧰 Changes

continuing my work in #1188 with
even more work to migrate over our tests to the more comprehensive
`runCommand` helper:

- [x] `openapi convert`
- [x] `openapi inspect`
- [x] `openapi reduce`
- [x] `login`
- [x] `logout`
- [x] `whoami`

the only outstanding tests using the now deprecated
`runCommandAndReturnResult` helper are the changelog tests, but i'll
swap those out if/when we get around to migrating that command over to
APIv2.

## 🧬 QA & Testing

no functional changes. do tests still pass?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command:openapi Issues pertaining to the `openapi`, `validate`, `reduce`, or `swagger` commands needs-backport-to-v9 refactor Issues about tackling technical debt released on @next
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants