Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger starts always the first debugged test #27

Open
MijikHna opened this issue Jul 25, 2023 · 2 comments
Open

Debugger starts always the first debugged test #27

MijikHna opened this issue Jul 25, 2023 · 2 comments

Comments

@MijikHna
Copy link

As nvim-dap repo suggests to use vscode-dap I have switched to vscode-dap. Also I have adjusted jester setup a accordingly. Here is my jester setup.

require'jester'.setup{
  cmd = "NODE_OPTIONS=--experimental-vm-modules node ./node_modules/jest/bin/jest.js -t \"$result\" $file", -- run command
  terminal_cmd = ":ToggleTerm",
  dap = {
    type = 'pwa-node',
    request = 'launch',
    name = 'Jest Debug',
    cwd = "${workspaceFolder}",
    rootPath = "${workspaceFolder}",
    runtimeExecutable = "node",
    runtimeArgs = {
      "./node_modules/jest/bin/jest.js",
      "--runInBand",
      "-t",
      "$result",
      "$file",
    },
    -- args = { "--runTestsByPath", "${relativeFile}" },
    args = { "--no-cache" },
    env = { NODE_OPTIONS = '--experimental-vm-modules' },
    sourceMaps = true,
    skipFiles = { "<node_internals>/**" },
    port=9229,
    console = 'integratedTerminal',
    disableOptimisticBPs = true
  },
}

also I have following mappings

nnoremap <silent> <leader>jr :lua require"jester".run()<CR>
nnoremap <silent> <leader>jd :lua require"jester".debug()<CR>

jester.run() works like expected by jester.debug() executes always the first debugged test. I always need to restart nvim to be able to debug second test.

@David-Kunz
Copy link
Owner

Hi @MijikHna ,

Could you try to log the output of config in

dap.run(config)

in

lua/jester/init.lua:184

?

@MijikHna
Copy link
Author

I have added dap.run(config) after line 184 now init.lua looks like this

...
    if string.match(value, "$file") then
      runtimeArgs[key] = runtimeArgs[key]:gsub("$file", file)
      local config = vim.tbl_deep_extend('force', o.dap, { type = type, request = request, cwd = cwd, runtimeArgs = runtimeArgs })
      dap.run(config)
    end
...

On starting debugger I get following error

E5108: Error executing lua /home/kirill/.config/nvim/plugged/nvim-dap/lua/dap.lua:470: attempt to index field 'config' (a nil value)
stack traceback:
        /home/kirill/.config/nvim/plugged/nvim-dap/lua/dap.lua:470: in function 'run'
        ...e/kirill/.config/nvim/plugged/jester/lua/jester/init.lua:193: in function 'cb'
        ...e/kirill/.config/nvim/plugged/jester/lua/jester/init.lua:288: in function 'cb'
        /home/kirill/.config/nvim/plugged/nvim-dap/lua/dap.lua:651: in function 'terminate'
        /home/kirill/.config/nvim/plugged/nvim-dap/lua/dap.lua:694: in function 'terminate'
        ...e/kirill/.config/nvim/plugged/jester/lua/jester/init.lua:287: in function 'terminate'
        ...e/kirill/.config/nvim/plugged/jester/lua/jester/init.lua:303: in function 'debug'
        [string ":lua"]:1: in main chunk

but the debugger starts and still always runs first executed test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants