Hi all, How do you guys test your RESTlets? Let's ...
# suitescript
m
Hi all, How do you guys test your RESTlets? Let's say I just need to know if the data was saved or not, how I can do that?
n
Use POSTman. Send request to your REStlet.
👍 1
r
you can also test in simple suitelet without worrying about setting all the auth up on postman
or client script
m
@NickSuite Sorry, had to go out.
Use POSTman. Send request to your REStlet.
This will tell you that the RESTlet is not failing, but it won't tell you it does what it should do.
n
Check the RESTlet script logs.
You should be returning the response on success which should tell you if your RESTlet is working fine or not..
m
Let me tell you my case, I have this 👆
I loop over it for validation against the JSON that I receive, if the field is not required, you ignore it if, so I need to make sure it actually saved all what I sent, and didn't ignore any field that should be ignored.
For any reason.
Sometimes your conditions could be wrong for example, you will still get 200
n
You will always get 200
200 is for the NetSuite/your RESTlet accepting the request. It has nothing to do whether your data is correct or not..
You can only that validation in your script and return the response accordingly.
m
I meant it will succeed, I know about the default 200 response
Never mind, I will do it manually
s
I generally doing integration testing like this from a pre-built jest harness. We also tend not to built separate restlets for a single cohesive API and instead build commands that are supported by a single restlet.
👍 1
For example with this approach, if write a restlet command that changes a sales order e.g. 'doSomethingToSalesOrder', I also include a 'getSalesOrder' command for testing that pulls the record data back. This allows us to do jest assertions to ensure the data was modified as expected based on the input payload sent to the first command.
for test validation purposes, simply getting the NFT representation of a record is usually all you need, so adding a
getRecordTypeX
securely to the API is usually either a one-line-of-code command or no-lines-of-code.
r
solid approach @Shawn Talbert
if you dont have the ability or time for shawn unit testing approach, we create a postman for each rest service or meathod on shared rest. you can save the inputs as well as output to quickly fire off a test and compare to previous
m
Yeah, I guess this could work for us 💯