2022-08-23 16:02:27 +02:00
|
|
|
|
|
|
|
local dap = require('dap')
|
|
|
|
|
|
|
|
local function debugJest(testName, filename)
|
|
|
|
print("starting " .. testName .. " in " .. filename)
|
|
|
|
dap.run({
|
2023-04-20 17:14:39 +02:00
|
|
|
type = 'node',
|
2022-08-23 16:02:27 +02:00
|
|
|
request = 'launch',
|
|
|
|
cwd = vim.fn.getcwd(),
|
|
|
|
runtimeArgs = {'--inspect-brk', '/usr/local/bin/jest', '--no-coverage', '-t', testName, '--', filename},
|
|
|
|
sourceMaps = true,
|
|
|
|
protocol = 'inspector',
|
|
|
|
skipFiles = {'<node_internals>/**/*.js'},
|
|
|
|
console = 'integratedTerminal',
|
|
|
|
port = 9229,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
local function attach()
|
|
|
|
print("attaching")
|
|
|
|
dap.run({
|
2023-04-20 17:14:39 +02:00
|
|
|
type = 'node',
|
2022-08-23 16:02:27 +02:00
|
|
|
request = 'attach',
|
|
|
|
cwd = vim.fn.getcwd(),
|
|
|
|
sourceMaps = true,
|
|
|
|
protocol = 'inspector',
|
|
|
|
skipFiles = {'<node_internals>/**/*.js'},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
local function attachToRemote()
|
|
|
|
print("attaching")
|
|
|
|
dap.run({
|
2023-04-20 17:14:39 +02:00
|
|
|
type = 'node',
|
2022-08-23 16:02:27 +02:00
|
|
|
request = 'attach',
|
|
|
|
address = "127.0.0.1",
|
|
|
|
port = 9229,
|
|
|
|
localRoot = vim.fn.getcwd(),
|
|
|
|
remoteRoot = "/home/vcap/app",
|
|
|
|
sourceMaps = true,
|
|
|
|
protocol = 'inspector',
|
|
|
|
skipFiles = {'<node_internals>/**/*.js'},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
debugJest = debugJest,
|
|
|
|
attach = attach,
|
|
|
|
attachToRemote = attachToRemote,
|
|
|
|
}
|
|
|
|
|