Mock a REST API Response in ATF

MarkC2
Kilo Contributor

We have a situation where we have a form that is making a REST call upon submission to an outside system to validate some data. We want to put automated testing around the form and it's various uses, but we need a way to catch that API call, stop it from making it, and provide a response to the system that is was successful, a failure, a timeout, etc. We don't want our test to be reliant on calling that outside system. If I could do with with Python, I would use a mock, but I'm unfamiliar with anything like that in JavaScript or if there's a way to do this in the automated test framework. Any suggestions?

2 REPLIES 2

Jace Benson
Mega Sage

You'd likely have to make a customized step config to do this but with that you could tell the config what endpoint, the payload, and the response data since you're making it all up anyways.

https://docs.servicenow.com/bundle/london-application-development/page/administer/auto-test-framewor...

I am heading up a open source project to make tests for all the things in servicenow, and this case hasn't come up but I can see how it would be useful.  Feel free to open an issue with a use case and I'll get it added.

https://atf.jacebenson.com

AJ9
Kilo Contributor

Hi Mark,

I came across this question couple days back. Have you found a solution for mocking an Outbound REST message in ATF  ? If yes, could you kindly share the details ?

Thanks!!