-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed as not planned
Closed as not planned
Copy link
Description
Clear and concise description of the problem
Currently, my tests must look like the following:
const bearerTokenApi1 = new BearerTokenApi(getApiConfig());
let response: GetTokenResponse | undefined;
try {
response = await bearerTokenApi1.bearerTokenRequestToken({
requestTokenRequest: {
userName: env.TOKEN_USERNAME,
password: env.TOKEN_PASSWORD,
},
});
} catch (error: unknown) {
const errorMessage = await getErrorMessage(error);
expect(errorMessage).toBe(undefined);
}
// Focus on these lines:
expect(response).toBeTruthy();
invariant(response);
The "invariant" function from tiny-invariant throws when falsy, similar to the .toBeTruthy()
but has proper type narrowing.
I believe expect(response).toBeTruthy()
should apply some sort of "asserts" to properly type narrow.
Suggested solution
expect(response).toBeTruthy();
invariant(response);
should become
expect(response).toBeTruthy();
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Zuruuh, swallowtail62, umar-ahmed, jaredmcateer, CSharpFiasco and 8 more
Metadata
Metadata
Assignees
Labels
No labels