【问题标题】:How do I add timeouts to .contains in Cypress using Typescript?如何使用 Typescript 在 Cypress 中向 .contains 添加超时?
【发布时间】:2018-10-16 12:26:13
【问题描述】:

我正在尝试将有效的柏树测试转换为打字稿。

以下行被标记为编译错误:

cy.contains("here's where you left off...",  {timeout: slowLoader })

错误信息说:

Argument of type '{ timeout: number; }' is not assignable to parameter of type 'string | number | RegExp'.
  Object literal may only specify known properties, and 'timeout' does not exist in type 'string | number | RegExp'.

slowLoader 上面定义为:

let slowLoader = 30000; // timeout time for slow loading elements

有什么建议吗?

【问题讨论】:

    标签: javascript typescript cypress


    【解决方案1】:

    查看我看到的文档后

    contains(selector, content, options)
    

    会不会是你需要传入

    cy.contains("SOME SELECTOR","here's where you left off...", {timeout: slowLoader })
    

    此测试以前是否仅在 JS 中工作?

    我的第一个想法是使用关键字来强制它

    cy.contains("here's where you left off...",<any> {timeout: slowLoader }),
    

    但我认为选项的参数位置错误

    【讨论】:

    • 这确实是错误的论点立场。 .contains(selector, content, options); 意味着 3 参数 .contains 应该类似于 'cy.contains('div', 'here's where you left off...', {timeout: slowLoader});`
    • 是的,我同意。我想知道测试是否曾经在 JS 与 TypeScript 中进行过
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-13
    • 2023-01-08
    • 1970-01-01
    • 2020-01-09
    • 1970-01-01
    • 2012-11-22
    相关资源
    最近更新 更多