I was just in between of my sample project, wherein I have just finished the backend design and I was writing the Client Side Test for Testing WEB-API, whether it is up and running. First of all, you need to install QUNIT For MVC from nuget. Upon, installing the same, it will bring QUNIT related files in Content and Scripts folder. However, for my sake of interest, I have kept the same under one folder as shown below in the screenshot.
However, let me share my custom snippets for the same 1st.
Then, API JS
Now, you can see in the above snippet. I have mentioned all my endpoints at one place, and API is trying to make an AJAX call to all of them one by one. As a result, when I open the HTML file in browser. This will produce me the below result.
Last one I purposely failed just to make a distinction between passed tests and failed tests. I mean, this sounds kind of nice to me, If I have to provide any flexibility to site users to check whether APIs are up and running. I hope you would have liked this discussion. Thanks for Joining me.
2,531 total views, 1 views today