Skip to content

Commit

Permalink
wip: neotest-jest 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
deptno committed Nov 6, 2023
1 parent 14733ae commit 566b348
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
1 change: 1 addition & 0 deletions lua/custom/configs/marks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ return {
'dapui_scopes',
'dapui_breakpoints',
'harpoon',
'neotest-output',
},
bookmark_1 = { sign = "1", virt_text = "🐮 1", annotate = false },
bookmark_2 = { sign = "2", virt_text = "🐮 2", annotate = false },
Expand Down
10 changes: 8 additions & 2 deletions lua/custom/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ M.harpoon = {
end,
"harpoon: toggle quick menu: cmd"
},
}
}
}
M.wip = {
n = {
Expand All @@ -678,7 +678,13 @@ M.wip = {
select_react_native_siblings()
end,
'wip: select react native siblings'
}
},

["<leader>n1"] = { function () require('neotest').run.run() end, 'wip' },
["<leader>n2"] = { function () require('neotest').run.run(vim.fn.expand('%')) end, 'wip' },
["<leader>n3"] = { function () require('neotest').summary.toggle() end, 'wip' },
["<leader>n4"] = { function () require('neotest').output_panel.toggle() end, 'wip' },
["<leader>n5"] = { function () require('neotest').output.open() end, 'wip' },
}
}

Expand Down
54 changes: 54 additions & 0 deletions lua/custom/plugins.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local get_git_root = require "lab.gx.lib.get_git_root"

return {
{
'folke/neodev.nvim',
Expand Down Expand Up @@ -365,5 +367,57 @@ return {
config = function ()
require("telescope").load_extension("harpoon")
end,
},
{
"nvim-neotest/neotest",
dependencies = {
"nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim",
"nvim-neotest/neotest-plenary",
"nvim-neotest/neotest-jest",
'marilari88/neotest-vitest',
},
opts = function ()
return {
status = { virtual_text = true },
output = { open_on_run = true },
adapters = {
require('neotest-plenary'),
require('neotest-vitest'),
require('neotest-jest')({
jestCommand = "yarn jest --",
env = { CI = true },
jestConfigFile = function()
local file = vim.fn.expand('%:p')
if string.find(file, "/packages/") then
local ret =
string.match(file, "(.-/[^/]+/)src") .. "jest.config.ts"
or string.match(file, "(.-/[^/]+/)src") .. "jest.config.js"

vim.print("configfile: " .. ret)
return ret
end

return vim.fn.getcwd() .. "/jest.config.ts"
end,
cwd = function(path)
local file = path or vim.fn.expand('%:p')
local git_root = get_git_root()
local relative_file = file:sub(#git_root + 1)
if string.find(relative_file, "/packages/") then
local ret = string.match(relative_file, "(.-/[^/]+/)src")

if ret then
return git_root .. ret
end

return ret
end
return vim.fn.getcwd()
end,
}),
}
}
end
}
}

0 comments on commit 566b348

Please sign in to comment.