-
Notifications
You must be signed in to change notification settings - Fork 174
How to use vimspector with vim test
Mika Andrianarijaona edited this page May 4, 2021
·
6 revisions
You can use the plugin vim-test
to start your vimspector
session.
Your debug adapter (using ${TestName}
as an input variable and a globally-installed jest
module):
{
"configurations": {
"jest": {
"adapter": "vscode-node",
"breakpoints": {
"exception": {
"all": "N",
"uncaught": "N"
}
},
"configuration": {
"request": "launch",
"name": "Debug Jest Test",
"type": "node",
"runtimeArgs": [
"--inspect-brk",
"/usr/local/bin/jest",
"--no-coverage",
"-t",
"'${TestName}'",
"--",
"${file}"
],
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**/*.js"],
"internalConsoleOptions": "neverOpen",
"port": 9229
}
}
}
}
Then you can add a test strategy in your vim configuration:
function! JestStrategy(cmd)
let testName = matchlist(a:cmd, '\v -t ''(.*)''')[1]
call vimspector#LaunchWithSettings( #{ configuration: 'jest', TestName: testName } )
endfunction
let g:test#custom_strategies = {'jest': function('JestStrategy')}
Now call :TestNearest -strategy=jest
to debug your test.