#michael3234324_best-practices
1 messages ¡ Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- michael3234324_59086, 2 days ago, 28 messages
đ Welcome to your new thread!
âąď¸ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime!
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1212499778462814228
đ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question. Thank you for your patience!
Hey there
No there isn't a way to do this. We recommend that you mock responses for your tests here.
You can also take advantage of Stripe Mock for this: https://github.com/stripe/stripe-mock
Thanks. Is there a standard way to "mock" requests to the api? When someone manually enters info, I am sending a Stripe object throughg the api in the frontend, and not sure how to "mock" that for unit testing.
I took a look at the github you linked and dont think it satisfies my use case.
I do need to send requests to the actual test api.
Yeah you can't hit the frontend programatically here.
So what you would do is do it once manually, take the output of the response and create a mock
Then your code returns that mock instead of hitting the API
Thanks for advising. Not sure if tahts exactly what I need, as I am actually trying to test the success statuses of various card brands from different countries, not just my frontend logic.
Can I simulate that from the backend instead?
That all depends on your integration, really.
But I'm not sure I even understand what you are testing in that case. Are you blocking certain brands or countries yourself?
Yea I understand its a bit hard to describe over text. Basically Im trying to write a holistic unit testing framework that simulates the entire frontend --> backend process.
What im understanding is that I cant really test frontend with the Stripe elements, so the next best thing for me would be to skip the frontend portion and only test my backend code.
Our business has a large number of options one can select for making payments and I need a way to test the entire flow for all of them. It would be impractical to maunally test every single combination of options.
Right, so you mock the pieces that you can't do programatically. There really isn't another way.
ok thanks for the help
Unless you pass raw PANs in your integration, then no, you can't do this solely via the backend.
But regardless, that would defeat the point of any test you write
As it would not be testing your actual integration.
Well, unless you actually do just handle everything via your backend.
Which you don't since you use Elements.
Right so i would need some schema that mocks the responses, that might be the best option
Yep
k thanks