How to test the backend in isolation

how do you isolate and unit test the backend code, and also is there a way to view the payload of these backend opertaions without connecting to the client ( like maybe some kind of API so i can just check the json and interact with it via postman?!? )
4 Replies
Filip
Filip10mo ago
Hi, @beatdown_kai, great question. I'll try to help you out. Let's first try to figure out what you want to do. You mentinoed both unit tests and postman, so I'm not sure I understood exactly what you need. Do you want to: - Unit test - test the backend functionality without the network (e.g., helper and business logic functions). - Test the API - test how the server handles request by sending HTTP requests to the server directly.
beatdown_kai
beatdown_kaiOP10mo ago
1. I want to be able to view whats going on with the backend code without having to write any client side code 2. I want to be able to isolate and unit test the backend code exactly like you said, just business logic / helper functions
Filip
Filip10mo ago
We don't have first-class support for server tests just yet, but you should be able to make your own
1. I want to be able to view whats going on with the backend code without having to write any client side code
You can always use postman and curl, as long as you have the correct payloads. Since Wasp uses an internal RPC (Queries and Actions), the payloads are somewhat internal and difficult to get right, but it's definitely possible. My recommendation is to run the client once, use the Dev tools to inspect the request, and copy it as "curl" (I think Postman lets you import curl commands).
2. I want to be able to isolate and unit test the backend code exactly like you said, just business logic / helper functions
For testing non-network related functions, you should be able to use the testing libraries framework you usually use - add the testing library to the project's package.json and set everything up as you normally would. I can help you out if you get stuck
beatdown_kai
beatdown_kaiOP10mo ago
ok cool, I will definitely ping you in an hour or so after i figure out these deployment issues lol. thankyou!
Want results from more Discord servers?
Add your server