Neovim for Beginners — Testing (Part 2)
Use Neovim for REST API testing, and explore new plugins for testing.
In this article, we are going to
- Explore plugins for REST API testing.
- Check out new plugins for testing.
This article is part of the Neovim for Beginners series.
The Neovim configuration files can be found in this repository.
This article is part 2 of the following articles related to testing.
REST API Testing
For REST API testing, there are several available plugins.
vim-rest-console
The vim-rest-console
plugin helps send requests to and display responses from RESTful services. It supports GET, POST, PUT, HEAD, PATCH, OPTIONS, and TRACE. This plugin requires cURL.
We will install this plugin using packer.nvim
.
use { "diepm/vim-rest-console", ft = { "rest" } }
Now create a file with an .rest
extension containing the following endpoint. Alternatively, we can set the file type to rest
(:set ft=rest
).
https://jsonplaceholder.typicode.comGET /posts
Press <C-j>
to execute the request.
Similarly, we can execute other kinds of requests. E.g. a POST request.
https://jsonplaceholder.typicode.comPOST /posts{
"userId": 1,
"id": 1,
"title": "post title",
"body": "post body"
}
Check out the project repository for more examples.
This plugin has more features like defining global definitions, specifying cURL options, posting data…