Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/David-Kunz/jester
A Neovim plugin to easily run and debug Jest tests
https://github.com/David-Kunz/jester
jest lua neovim nvim-dap plugin
Last synced: about 2 months ago
JSON representation
A Neovim plugin to easily run and debug Jest tests
- Host: GitHub
- URL: https://github.com/David-Kunz/jester
- Owner: David-Kunz
- License: unlicense
- Created: 2021-07-11T15:51:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-01T06:54:39.000Z (over 1 year ago)
- Last Synced: 2024-07-31T20:51:09.202Z (4 months ago)
- Topics: jest, lua, neovim, nvim-dap, plugin
- Language: Lua
- Homepage:
- Size: 43.9 KB
- Stars: 194
- Watchers: 3
- Forks: 11
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - David-Kunz/jester - Easily run and debug Jest tests. (Test / Quickfix)
- awesome-jest - jester
README
# jester
A [Neovim](https://neovim.io/) plugin to easily run and debug [Jest](https://jestjs.io/) tests.
![jester](https://user-images.githubusercontent.com/1009936/125203183-ba543b00-e277-11eb-83a2-d7fe912cdec8.gif)
## Installation
Requirements: [Neovim](https://neovim.io/), [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter), for debugging [nvim-dap](https://github.com/mfussenegger/nvim-dap).
Make sure that the JavaScript/TypeScript parser for [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) is installed and enabled.
For [vim-plug](https://github.com/junegunn/vim-plug):
```
Plug 'David-Kunz/jester'
```
For [packer](https://github.com/wbthomason/packer.nvim):
```
use 'David-Kunz/jester'
```## Usage
### Run nearest test(s) under the cursor
```
:lua require"jester".run()
```### Run current file
```
:lua require"jester".run_file()
```### Run last test(s)
```
:lua require"jester".run_last()
```### Debug nearest test(s) under the cursor
```
:lua require"jester".debug()
```### Debug current file
```
:lua require"jester".debug_file()
```### Debug last test(s)
```
:lua require"jester".debug_last()
```## Options
You can specify global options using the `setup` function.
Example:
```lua
require("jester").setup({
dap = {
console = "externalTerminal"
}
})
```These are the defaults:
```lua
{
cmd = "jest -t '$result' -- $file", -- run command
identifiers = {"test", "it"}, -- used to identify tests
prepend = {"describe"}, -- prepend describe blocks
expressions = {"call_expression"}, -- tree-sitter object used to scan for tests/describe blocks
path_to_jest_run = 'jest', -- used to run tests
path_to_jest_debug = './node_modules/.bin/jest', -- used for debugging
terminal_cmd = ":vsplit | terminal", -- used to spawn a terminal for running tests, for debugging refer to nvim-dap's config
dap = { -- debug adapter configuration
type = 'node2',
request = 'launch',
cwd = vim.fn.getcwd(),
runtimeArgs = {'--inspect-brk', '$path_to_jest', '--no-coverage', '-t', '$result', '--', '$file'},
args = { '--no-cache' },
sourceMaps = false,
protocol = 'inspector',
skipFiles = {'/**/*.js'},
console = 'integratedTerminal',
port = 9229,
disableOptimisticBPs = true
}
}
```You can also overwrite the options for each function call, for example
```lua
:lua require"jester".debug({ dap = { console = "externalTerminal" } })
```## Tip
Jest usually transforms the files causing breakpoints to be inserted in the wrong line.
To prevent this, add this `.babelrc` file to your project's root:```json
{
"retainLines": true,
"sourceMap": "inline"
}
```