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

Add test for CredentialFetchingError #899

Merged
merged 1 commit into from
May 4, 2023
Merged

Conversation

mctofu
Copy link
Contributor

@mctofu mctofu commented May 4, 2023

In #898 I ran into issues testing the handling of errors from the api-client module in main.ts. This fixes the mocking related issues around that and adds an additional test for the existing behavior using the CredentialFetchingError from api-client

Failure to retrieve credentials because of a bad API response raises a CredentialFetchingError which has different error handling.

The automatic mocking from jest.mock(../src/api-client) was interfering with the instanceof checks in the error handler so I've removed it and replaced with mocks on individual api-client methods. I tried to use a custom mock factory as an alternative but it was much more complex and I couldn't get a working solution that worked with the error handlers and allowed spying on the ApiClient.prototype.

Failure to retrieve credentials because of a bad API response raises a
CredentialFetchingError which has different error handling.

The automatic mocking from jest.mock(../src/api-client) as interfering
with the instanceof checks in the error handler so I've removed it and
replaced with mocks on individual api-client methods. I tried to use a
custom mock factory as an alternative but it was much more complex and
I couldn't get a working solution that worked with the error handlers
and allowed spying on the ApiClient.prototype.
@mctofu mctofu requested a review from a team as a code owner May 4, 2023 16:49
@mctofu mctofu merged commit 2425e15 into main May 4, 2023
9 checks passed
@mctofu mctofu deleted the mctofu/main-test-accuracy branch May 4, 2023 18:06
@mctofu mctofu mentioned this pull request Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants