From 19a23e9dad94815c8c665d7d96428c08c6b61b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crist=C3=B3bal=20Gajardo=20Vera?= Date: Thu, 5 Sep 2024 14:22:18 -0400 Subject: [PATCH] feat(typescript): add neotest-jest support (#1189) * feat(typescript): add neotest-jest support * add missing empty config function * Update README --------- Co-authored-by: Micah Halter --- lua/astrocommunity/pack/typescript/README.md | 16 ++++++++++++++++ lua/astrocommunity/pack/typescript/init.lua | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/lua/astrocommunity/pack/typescript/README.md b/lua/astrocommunity/pack/typescript/README.md index c0c2a4f7c..bbdd9bf24 100644 --- a/lua/astrocommunity/pack/typescript/README.md +++ b/lua/astrocommunity/pack/typescript/README.md @@ -10,6 +10,7 @@ This plugin pack does the following: - Adds [nvim-vtsls](https://github.com/yioneko/nvim-vtsls) for language specific tooling - Adds [package-info.nvim](https://github.com/vuki656/package-info.nvim) for project package management - Adds [nvim-lsp-file-operations](https://github.com/antosha417/nvim-lsp-file-operations) to handles file imports on rename or move within neo-tree +- Adds [neotest-jest](https://github.com/nvim-neotest/neotest-jest) to ease the test running if `neotest` is installed ## How do I disable Eslint format on save? @@ -26,3 +27,18 @@ return { }, } ``` + +## How do I customize `neotest-jest`? + +To customize the `neotest-jest` plugin, you need to configure it like you would with any other plugin + +> Learn more about the spec setup used by `lazy` [here](https://lazy.folke.io/spec#spec-setup). + +```lua +---@type LazySpec +return { + "nvim-neotest/neotest-jest", + opts = function(_, opts) + -- Add your opts + end, +} diff --git a/lua/astrocommunity/pack/typescript/init.lua b/lua/astrocommunity/pack/typescript/init.lua index a65c5e676..022edbfaa 100644 --- a/lua/astrocommunity/pack/typescript/init.lua +++ b/lua/astrocommunity/pack/typescript/init.lua @@ -233,4 +233,13 @@ return { }, }, }, + { + "nvim-neotest/neotest", + optional = true, + dependencies = { { "nvim-neotest/neotest-jest", config = function() end } }, + opts = function(_, opts) + if not opts.adapters then opts.adapters = {} end + table.insert(opts.adapters, require "neotest-jest"(require("astrocore").plugin_opts "neotest-jest")) + end, + }, }