【问题标题】:Cypress `onCall()` assertion support seems not documented?Cypress `onCall()` 断言支持似乎没有记录?
【发布时间】:2018-09-18 17:33:33
【问题描述】:

this cypress example 中,我发现onCall() 方法似乎是“Sinon”,因为我发现它here。 Cypress 中支持的断言提到了here,它包括sinon-chai,其中没有提到onCall()

我的问题:究竟支持哪些断言,因为 onCall() 支持似乎没有记录在案?

【问题讨论】:

    标签: javascript sinon assertions sinon-chai cypress


    【解决方案1】:

    Cypress 存根和间谍实际上只是 sinon 存根和间谍,尽管具有更多仅存在于 Cypress 中的功能。

    但是,返回的底层实例来自 sinon,因此如文档中所述,所有来自 sinon 的方法都可用于这些实例。

    https://docs.cypress.io/api/commands/stub.html#Yields

    onCall 来自 sinon - 它不是断言 - 它只是您在 stub/spy 上调用的一种方法,以作为该调用的一部分访问事物。

    这就是为什么它没有在断言中记录的原因 - 除了这个之外,还有许多其他有用的方法,我会参考 sinons 文档来看看你会如何使用它们。

    在这些文档中查找 onCall 方法:http://sinonjs.org/releases/v4.5.0/stubs/

    要回答这个问题:确切支持哪些断言,这就是此处指南中记录的内容:https://docs.cypress.io/guides/references/assertions.html#Sinon-Chai

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-16
      • 2016-06-24
      • 2019-09-05
      • 1970-01-01
      • 1970-01-01
      • 2018-03-20
      • 1970-01-01
      • 2019-12-17
      相关资源
      最近更新 更多