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
Type 'Promise<any>' is not assignable to type 'CanReturnChainable' in Cypress #7807
Comments
@stevenvachon Hey, can you provide some more info?
I can't recreate this just adding this code to a |
@jennifer-shehane I'm seeing similar behavior.
Cypress.Commands.add(
"createReview",
(payload: Partial<CreateReviewPayload>) => {
const review = cleanObject<CreateReviewPayload>({
title: payload.title || `[cy-test]`,
description: "This is a review created for test purposes",
tagIds: [],
industryId: "__no_industry",
type: "self-review",
accountId: testAccountId,
...payload,
});
return functions
.httpsCallable("createReview")(review)
.then((result) => {
const reviewId = result.data.reviewId as string;
return firestore
.collection("reviews")
.doc(reviewId)
.get()
.then((snap) => ({
id: reviewId,
data: snap.data() as Review,
}));
});
},
); Error:
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "preserve",
"lib": ["dom", "esnext"],
"types": ["cypress", "node"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveConstEnums": true,
"removeComments": false,
"skipLibCheck": true,
"checkJs": false,
"sourceMap": true,
"strict": true,
"target": "es2018",
"allowJs": false,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"baseUrl": ".",
"paths": {
"/*": ["./src/*"]
}
}
} For me this issue also started when upgrading from 4.8 to 4.9 |
@jennifer-shehane @0x80 I faced the same situation here, but with MailSlurp service: import { MailSlurp } from 'mailslurp-client';
const getMailSlurpInstance = (apiKey: string) => {
return new MailSlurp({ apiKey });
};
Cypress.Commands.add('createInbox', (apiKey: string) => {
return getMailSlurpInstance(apiKey).createInbox();
}); This expected type from the command |
This issue also appears in 5.0.0 |
Confirmed. Trying to find the fix. |
I worked around it by returning my promise prefixed with |
The code for this is done in cypress-io/cypress#8501, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
Having updated from Cypress 4.8, TypeScript will now not compile my support code. #435 was not insightful.
Desired behavior:
Compile my TypeScript. Either I'm doing something wrong or there is a bug.
Test code to reproduce
It fails similarly with
Cypress.Promise
as well. I'd like to avoidcy.wrap()
unless necessary.Versions
Cypress 4.9.0
macOS 10.15.5
Chrome 83
The text was updated successfully, but these errors were encountered: