David-Kunz/jester

github github
test plugin
star 26
stars
alert-circle 0
open issues
users 1
subscribers
git-branch 0
forks
CREATED

2021-07-11

UPDATED

2 days ago

packer

require('packer').startup(function()
  use 'David-Kunz/jester'
end)

paq

require "paq" { 
  'David-Kunz/jester'
}

jester

A Neovim plugin to easily run and debug Jest tests.

jester

Installation

Requirements: Neovim >= 0.5, nvim-treesitter, for debugging nvim-dap

For vim-plug:

Plug 'David-Kunz/jester'

For packer:

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 options for all functions, these are the defaults:

{
  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 = './node_modules/bin/jest' -- used only for debugging
  dap = { -- debug adapter configuration
    type = 'node2',
    request = 'launch',
    cwd = vim.fn.getcwd(),
    runtimeArgs = {'--inspect-brk', 'node_modules/.bin/jest', '--no-coverage', '-t', '$result', '--', '$file'},
    sourceMaps = true,
    protocol = 'inspector',
    skipFiles = {'<node_internals>/**/*.js'},
    console = 'integratedTerminal',
    port = 9229
  }
}