【问题标题】:Testing Google Pay via Stripe in cypress在 cypress 中通过 Stripe 测试 Google Pay
【发布时间】:2023-03-03 08:37:23
【问题描述】:

我正在尝试编写与 react-stripe-js 的 PaymentRequestButtonElement 组件交互的赛普拉斯测试。不幸的是,我在实际让我的测试渲染按钮时遇到了一点绊脚石(当我手动测试时工作正常)。

我试过模拟窗口的PaymentRequest 函数:

          cy.window().then(win => {
            if (win.PaymentRequest) {
              // If we’re running in headed mode
              cy.stub(win, 'PaymentRequest').callsFake(getMockPaymentRequest(validPaymentRequestResponse));
            } else {
              // else headless
              win.PaymentRequest = getMockPaymentRequest(validPaymentRequestResponse)
            }
          });

但运气不好,我们的按钮仍然没有出现。我怀疑这与我在控制台中看到的以下错误有关: Unable to download payment manifest "https://google.com/pay".,但通过谷歌浏览了一下,似乎没有人提到这一点。

我也尝试过以类似方式存根 window.Stripe(模拟 stripe.paymentRequest 函数),但同样没有运气。

有没有人成功实现过类似的东西?

【问题讨论】:

  • 无法下载付款清单 "google.com/pay" 只是一些噪音。这不是根本原因。我以前没有用过柏树,所以在这里帮不上忙。

标签: stripe-payments cypress google-pay


【解决方案1】:

为了在 Cypress 中测试 Stripe 的付款请求按钮,您可能需要mock the Payment Request API

现在所有部分都已就绪,我们可以尝试测试一些更复杂的东西,即 Stripe 方便地为我们包装的支付请求 API。

此 API 用于检测浏览器是否支持 Apple 或 Google Pay 等付款方式,然后通过这些 API 处理接受付款。

【讨论】:

    猜你喜欢
    • 2016-04-24
    • 2020-10-05
    • 2020-06-06
    • 1970-01-01
    • 2020-05-05
    • 2021-09-02
    • 1970-01-01
    • 2015-01-19
    • 1970-01-01
    相关资源
    最近更新 更多