Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: declare jest available if the binary exists in node_modules/.bin #130

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lua/neotest-jest/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ local parameterized_tests = require("neotest-jest.parameterized-tests")
---@type neotest.Adapter
local adapter = { name = "neotest-jest" }

local rootJestBinary = vim.fn.getcwd() .. "/node_modules/.bin/jest"
local rootPackageJson = vim.fn.getcwd() .. "/package.json"

local function rootProjectHasJestBinary()
local success = pcall(lib.files.read, rootJestBinary)
return success
end

---@return boolean
local function rootProjectHasJestDependency()
if rootProjectHasJestBinary() then
return true
end

local path = rootPackageJson

local success, packageJsonContent = pcall(lib.files.read, path)
Expand Down