Open David-Kunz opened 1 year ago
Hi! Thank you for the kind words :)
nvim-dap
will open a scratch buffer when it is unable to locate the requested source file. Have you provided the cwd
and rootPath
keys in your configuration? For example:
{
name = "Debug Jest Tests",
type = "pwa-node",
request = "launch",
-- ...
rootPath = "${workspaceFolder}",
cwd = "${workspaceFolder}",
}
If that doesn't work, I can probably help more if you send your adapter config and a simple example, since I am unable to replicate the issue!
Hi @mxsdev ,
Thanks a lot for your reply and suggestion!
I added both rootPath
and cwd
and set it to my current workspace folder, unfortunately it still uses the scratch buffer.
Here's a minimal example:
mkdir test && cd test;
npm init -y
npm i jest
sample.test.js
test('foo', () => {
const myObj = { a: { foo: 1 } }
expect(1).toBe(1) // set breakpoint here
})
_G.test_dap = function()
local dap = require'dap'
dap.run({
type = 'pwa-node',
request = 'launch',
cwd = '<path_to_test_folder>',
rootPath = '<path_to_test_folder>',
runtimeArgs = {'--inspect-brk', './node_modules/.bin/jest', '--no-coverage', '-t', '^foo$', '--', 'sample.test.js'},
args = { '--no-cache' },
console = 'integratedTerminal',
})
end
sample.test.js
:lua test_dap()
Notice that you automatically switched to the scratch buffer and the content of the file changed to
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){test('foo', () => {
const myObj = { a: { foo: 1 } }
expect(1).toBe(1)
})
}});
Hi 👋 ,
First of all, thanks for this nice plugin, it works very well, also in combination with my plugin jester.
One thing that bothers me a bit is that when debugging Jest tests, the debugger always stops in a readonly scratch buffer, hence it's not possible to perform some ad-hoc changes. On the other hand, the
node2
debugger directly stops in the same file where the breakpoint is set making the whole experience better.Do you know of any way to prevent stopping in scratch buffers?
Note: The scratch buffers for the jest test themselves are transformed, I tried to prevent this using the Jest config
but it didn't help.
Thanks again and best regards, David