How to never leave VSCode for testing your HTTP/JSON APIs

How to never leave VSCode for testing your HTTP/JSON APIs

Over the last few years, I’ve gone through various tools for testing HTTP/JSON APIs that I’ve developed. I (obviously) started with cURL, having copied various snippets from StackOverflow. Then, I migrated to Postman, which let me repurpose components of requests while not having to navigate the terminal to modify headers and such (with cURL) - Postman also needed me to do a lot of Googling to figure out the right syntax. 

More recently, I’ve been exploring ways of not having to leave my IDE, to further optimize for the decrease in productivity due to context switching. VSCode is my IDE of choice and these are the following tools that I’ve been using recently:

  1. cURL
  2. Integration tests using language-specific HTTP clients
  3. Thunder Client (in VSCode marketplace)
  4. REST Client (in VSCode marketplace)

Here’s my experience using each of these, followed by a score of convenience and shareability. I will use an API I have been working on at DevZero, for each of the tools.

How to use cURL to test endpoints in VSCode

This is a basic request where I have to keep updating the paths and/or the headers till things work. It’s really good for when you want to test the first time that an API works, but starts to get quite cumbersome after - you have to keep scrubbing words (headers, body contents, etc) in the request which takes a lot of time. Unnecessary.

Developer Productivity, API Testing, VSCode, HTTP/JSON testing, cURL in VSCode, Remote Development, Optimization

How to use integration tests to test endpoints in VSCode

This option is great for iterating, but it's kinda time-consuming to get started. Since things are within an IDE and usually operating as a unit test, it’s easy to iterate on as part of the basic IDE debug workflow (I use dlv for Go).

How to use Thunder Client to test endpoints in VSCode

Thunder makes it super easy to iterate on header or body contents. It’s great for the individual developer use-case, especially with the concept of collections and how it “remembers” past requests. Thunder definitely requires the least number of keystrokes/clicks to get to results.

Developer Productivity, API Testing, VSCode, HTTP/JSON testing, cURL in VSCode, Remote Development, Optimization

How to use REST Client to test endpoints in VSCode

The REST Client makes it very easy to check in test requests, provided everyone on the team has the REST Client installed to make the test calls. It requires some Googling to get the syntax right when setting up the first request, but the ease of shareability by checking in the *.http file makes it the best solution for teams.

Developer Productivity, API Testing, VSCode, HTTP/JSON testing, cURL in VSCode, Remote Development, Optimization

Conclusion

  • Thunder Client is the best for individual testing, optimized for quick feedback loops. 
  • REST Client is the best choice for teams due to the ease of shareability. 

All free DevZero templates that have HTTP projects within, will have Thunder Client installed by default. They will also have test *.http files readable by REST Client present.

Tags: Developer Productivity, API Testing, VSCode, HTTP/JSON testing, cURL in VSCode, Remote Development, Optimization

Other posts