Test Runner for neovim
Language | Test Runners |
---|---|
Go | Go go-test |
Javascript | Mocha mocha , Jest jest |
Lua | Busted busted |
Python | PyTest pytest , PyUnit pyunit |
Rust | Cargo cargo-test |
Typescript | TS-Mocha ts-mocha |
with packer:
use {
"klen/nvim-test",
config = function()
require('nvim-test').setup()
end
}
The plugin defines the commands:
TestNearest
- run the test nearest to the cursorTestFile
- run all tests in the current fileTestSuite
- run the whole test suiteTestLast
- run the last testTestVisit
- open the last run test in the current bufferTestInfo
- show an information about the plugin
This plugin must be explicitly enabled by using require("nvim-test").setup{}
Default options:
require('nvim-test').setup {
commands_create = true, -- create commands (TestFile, TestLast, ...)
silent = false, -- less notifications
run = true, -- run test commands
term = "terminal", -- a terminal to run (terminal|toggleterm)
termOpts = {
direction = "vertical", -- terminal's direction (horizontal|vertical|float)
width = 96, -- terminal's width (for vertical|float)
height = 24, -- terminal's height (for horizontal|float)
go_back = false, -- return focus to original window after executing
stopinsert = false, -- exit from insert mode
keep_one = true, -- only for term 'terminal', use only one buffer for testing
},
runners = { -- setup tests runners
go = "nvim-test.runners.go-test",
javascript = "nvim-test.runners.jest",
lua = "nvim-test.runners.busted",
python = "nvim-test.runners.pytest",
rust = "nvim-test.runners.cargo-test",
typescript = "nvim-test.runners.jest",
}
}
Setup a runner:
require('nvim-test.runners.jest').setup {
command = "~/node_modules/.bin/jest",
args = " --collectCoverage=false ",
}