#michael3234324_best-practices

1 messages ¡ Page 1 of 1 (latest)

hollow havenBOT
willow quarryBOT
#

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.

hollow havenBOT
#

👋 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!

willow quarryBOT
coarse elk
#

Hey there

#

No there isn't a way to do this. We recommend that you mock responses for your tests here.

hallow wedge
#

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.

coarse elk
#

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

hallow wedge
#

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?

coarse elk
#

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?

hallow wedge
#

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.

coarse elk
#

Right, so you mock the pieces that you can't do programatically. There really isn't another way.

hallow wedge
#

ok thanks for the help

coarse elk
#

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.

hallow wedge
#

Right so i would need some schema that mocks the responses, that might be the best option

coarse elk
#

Yep

hallow wedge
#

k thanks