I myself have done it on many mobile app development projects for rapid development and functional testing.
However, using Node.js to return stubbed response payloads is a great alternate approach for mocking business layer or server behavior.
I will outline the four main reasons why I have chosen to always use this alternate approach for mocking the services layer response:
- The developer can verify the request data, as the Node.js server simulator will display the headers as well as the body of the request.
- The ports assigned to the server can be changed dynamically and on the fly.
- It is easy to install, and there’s no need configure. Developers who have experienced the process of configuring and troubleshooting the httpd.conf file, often a meticulous and cumbersome process, will especially appreciate this reason.
- Different scenarios can be tested by adding logic on an ad hoc basis (such as inspecting elements of a request and generating a different response).
Can you think of any other reasons to add to this list? If yes, then please tweet it my way on Twitter.