admin管理员组文章数量:1314488
In a .ts file I create a test to try and access a custom created mand from mand.js, createInbox
function is underlined with red with the following message : Property 'createInbox' does not exist on type 'cy & EventEmitter
it.only('dsdsds', () => {
cy.createInbox().then((inbox) => {
console.log(inbox);
// { id: '...', emailAddress: '...' }
});
})
My mand.js file look like this
const { MailSlurp } = require("mailslurp-client");
const mailslurp = new MailSlurp(Cypress.env("mailSlurpApiKey"));
Cypress.Commands.add("createInbox", () => {
return mailslurp.createInbox();
});
Cypress.Commands.add("waitForLatestEmail", (inboxId) => {
return mailslurp.waitForLatestEmail(inboxId);
});
I understand that I have to rename mand.js to ts, however when I do that all custom mands is underlined with red with the following error : Argument of type '"waitForLatestEmail"' is not assignable to parameter of type 'keyof Chainable
How could I fix this?
In a .ts file I create a test to try and access a custom created mand from mand.js, createInbox
function is underlined with red with the following message : Property 'createInbox' does not exist on type 'cy & EventEmitter
it.only('dsdsds', () => {
cy.createInbox().then((inbox) => {
console.log(inbox);
// { id: '...', emailAddress: '...' }
});
})
My mand.js file look like this
const { MailSlurp } = require("mailslurp-client");
const mailslurp = new MailSlurp(Cypress.env("mailSlurpApiKey"));
Cypress.Commands.add("createInbox", () => {
return mailslurp.createInbox();
});
Cypress.Commands.add("waitForLatestEmail", (inboxId) => {
return mailslurp.waitForLatestEmail(inboxId);
});
I understand that I have to rename mand.js to ts, however when I do that all custom mands is underlined with red with the following error : Argument of type '"waitForLatestEmail"' is not assignable to parameter of type 'keyof Chainable
How could I fix this?
Share Improve this question edited May 13, 2022 at 10:15 VincenzoC 31.5k12 gold badges100 silver badges121 bronze badges asked May 13, 2022 at 9:27 Artjom ProzorovArtjom Prozorov 3274 silver badges10 bronze badges2 Answers
Reset to default 4I had this problem aswell! My solution: I had my *.d.ts files located inside the cypress/support folder, right next to the *.ts files with all the custom mands. Moving those outside(!) the "support"-folder and into another one called "definitionFiles" (for example) worked beautifully!
Solved by adding custom chainable interface to support folder
declare namespace Cypress {
interface Chainable {
createInbox(): Chainable<any>;
waitForLatestEmail(inboxId: number): Chainable<any>;
}
}
本文标签:
版权声明:本文标题:javascript - Custom cypress commands is not assignable to parameter of type 'keyof Chainable<any> - Stack 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741968036a2407664.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论