From 9bbe8a6e5d74d349a4e68a8a53c09a0ffe84c550 Mon Sep 17 00:00:00 2001 From: Asep Komarudin <68836805+pojokcodeid@users.noreply.github.com> Date: Thu, 13 Jun 2024 21:27:48 +0700 Subject: [PATCH] Updated 7. Example Custom Plugins (markdown) --- 7.-Example-Custom-Plugins.md | 94 ++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/7.-Example-Custom-Plugins.md b/7.-Example-Custom-Plugins.md index b8fb090..a5d8841 100644 --- a/7.-Example-Custom-Plugins.md +++ b/7.-Example-Custom-Plugins.md @@ -2875,4 +2875,98 @@ return { }, }, } +``` +# Neotest-Jest +```lua +return { + "nvim-neotest/neotest", + dependencies = { + "nvim-neotest/neotest-jest", + "nvim-neotest/nvim-nio", + }, + config = function() + require("neotest").setup { + adapters = { + require "neotest-jest" { + jestCommand = "npm test -- ", + jestConfigFile = function() + local file = vim.fn.expand "%:p" + if string.find(file, "/packages/") then + return string.match(file, "(.-/[^/]+/)src") .. "jest.config.mjs" + end + return vim.fn.getcwd() .. "/jest.config.mjs" + end, + env = { CI = true }, + cwd = function() + local file = vim.fn.expand "%:p" + if string.find(file, "/packages/") then + return string.match(file, "(.-/[^/]+/)src") + end + return vim.fn.getcwd() + end, + status = { virtual_text = true }, + output = { open_on_run = true }, + }, + }, + } + end, + keys = { + { + "Tt", + function() + require("neotest").run.run(vim.fn.expand "%") + end, + desc = "Run File", + }, + { + "Tr", + function() + require("neotest").run.run() + end, + desc = "Run Nearest", + }, + { + "TT", + function() + require("neotest").run.run(vim.loop.cwd()) + end, + desc = "Run All Test Files", + }, + { + "Tl", + function() + require("neotest").run.run_last() + end, + desc = "Run Last", + }, + { + "Ts", + function() + require("neotest").summary.toggle() + end, + desc = "Toggle Summary", + }, + { + "To", + function() + require("neotest").output.open { enter = true, auto_close = true } + end, + desc = "Show Output", + }, + { + "TO", + function() + require("neotest").output_panel.toggle() + end, + desc = "Toggle Output Panel", + }, + { + "TS", + function() + require("neotest").run.stop() + end, + desc = "Stop", + }, + }, +} ``` \ No newline at end of file