Skip to content
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
13 changes: 10 additions & 3 deletions lua/neotest-jest/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ local function parsed_json_to_results(data, output_file, consoleOut)
return tests
end

local function reducePattern(cwd, path)
local normalized_cwd = vim.fn.resolve(vim.fs.normalize(cwd) .. '/')
local normalized_path = vim.fs.normalize(path)

return vim.fn.substitute(normalized_path, normalized_cwd, '', 'g');
end

---@param args neotest.RunArgs
---@return neotest.RunSpec | nil
function adapter.build_spec(args)
Expand Down Expand Up @@ -409,6 +416,8 @@ function adapter.build_spec(args)
table.insert(command, "--config=" .. config)
end

local cwd = getCwd(pos.path)

vim.list_extend(command, {
"--no-coverage",
"--testLocationInResults",
Expand All @@ -417,11 +426,9 @@ function adapter.build_spec(args)
"--outputFile=" .. results_path,
"--testNamePattern=" .. testNamePattern,
"--forceExit",
escapeTestPattern(vim.fs.normalize(pos.path)),
escapeTestPattern(reducePattern(cwd, pos.path)),
})

local cwd = getCwd(pos.path)

-- creating empty file for streaming results
lib.files.write(results_path, "")
local stream_data, stop_stream = util.stream(results_path)
Expand Down