From cbd97eab7b61379dd4af0ccbab0166a67a27f14a Mon Sep 17 00:00:00 2001 From: Benji Stephenson Date: Mon, 12 Aug 2024 15:14:57 +0100 Subject: [PATCH] feat: add support for @swc/jest package as a jest provider --- lua/neotest-jest/init.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/neotest-jest/init.lua b/lua/neotest-jest/init.lua index a199bb7..8b811ea 100644 --- a/lua/neotest-jest/init.lua +++ b/lua/neotest-jest/init.lua @@ -18,6 +18,12 @@ local adapter = { name = "neotest-jest" } local rootPackageJson = vim.fn.getcwd() .. "/package.json" +---@param package string +---@return boolean +local function isSupportedJestPackage(package) + return package == "jest" or package == "@swc/jest" +end + ---@return boolean local function rootProjectHasJestDependency() local path = rootPackageJson @@ -32,7 +38,7 @@ local function rootProjectHasJestDependency() if parsedPackageJson["dependencies"] then for key, _ in pairs(parsedPackageJson["dependencies"]) do - if key == "jest" then + if isSupportedJestPackage(key) then return true end end @@ -40,7 +46,7 @@ local function rootProjectHasJestDependency() if parsedPackageJson["devDependencies"] then for key, _ in pairs(parsedPackageJson["devDependencies"]) do - if key == "jest" then + if isSupportedJestPackage(key) then return true end end @@ -68,7 +74,7 @@ local function hasJestDependency(path) if parsedPackageJson["dependencies"] then for key, _ in pairs(parsedPackageJson["dependencies"]) do - if key == "jest" then + if isSupportedJestPackage(key) then return true end end @@ -76,7 +82,7 @@ local function hasJestDependency(path) if parsedPackageJson["devDependencies"] then for key, _ in pairs(parsedPackageJson["devDependencies"]) do - if key == "jest" then + if isSupportedJestPackage(key) then return true end end