#richardzalay-automation-googlepay
1 messages · Page 1 of 1 (latest)
Hi, can you specify where are you seeing that skipEnrollmentChecks?
GooglePay would be "available" on a device with GooglePay setup. Are you running automated UI on real devices?
skipEnrollmentChecks -> by stepping into paymentRequest.canMakePayment
Our 'fast' target for automated tests is a Chrome browser with device emulation on
Google Pay won't actually be setup, I'd like to bypass that check and mock the PaymentRequest response.
Usually I would assume that simply mocking PaymentRequest.prototype.canMakePayment would be sufficient (which we do for other payment gateways, and also for Apple Pay on Stripe with window.ApplePaySession)
Hey sorry for late response. I have been in MTGs
No problem, you don't owe me your time 🙂
Yeah I think mocking canMakePayment() could be enough. That method decide whether to mount the button or not.
It seems to ignore it, though
PaymentRequest.prototype.canMakePayment = () => Promise.resolve(true);
I do see that it's doing some messaging, possibly from a service worker?
Perhaps it's doing the PaymentRequest check in there instead?
After swapping it like that you still see it sent messages?
only by displaying the button (not touching it)?
I mean that even with that mock in place, calling Stripe's paymentRequest.canMakePayment still returns { googlePay: false }
Something like:
PaymentRequest.prototype.canMakePayment = () => Promise.resolve(true);
const stripe = await loadStripe(API_KEY);
const paymentRequest = stripe.paymentRequest({
country: "AU",
currency: "AUD",
total: {
label: "test",
amount: 100,
}
});
const result = await paymentRequest.canMakePayment();
console.log(result.googlePay) // false
How about mocking by wrapping that method into a custom method?
then swap the wrapper method instead
Thanks. That might work. I was hoping to do it with a lighter hand though