Skip to content

Commit

Permalink
checks for missing assertionResults
Browse files Browse the repository at this point in the history
  • Loading branch information
nhomble committed Aug 2, 2024
1 parent 353364a commit 8037c33
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lua/neotest-vitest/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ end

local function parsed_json_to_results(data, output_file, consoleOut)
local tests = {}

for _, testResult in pairs(data.testResults) do
local testFn = testResult.name

if testResult.assertionResults == nil then return tests end
for _, assertionResult in pairs(testResult.assertionResults) do
local status, name = assertionResult.status, assertionResult.title

Expand Down Expand Up @@ -330,7 +330,6 @@ function adapter.build_spec(args)
if pos.type == "namespace" then
testNamePattern = "^ " .. escapeTestPattern(pos.name)
end

local binary = args.vitestCommand or getVitestCommand(pos.path)
local config = getVitestConfig(pos.path) or "vitest.config.js"
local command = vim.split(binary, "%s+")
Expand Down Expand Up @@ -370,13 +369,11 @@ function adapter.build_spec(args)
if not new_results or new_results == "" then
return {}
end

local ok, parsed = pcall(vim.json.decode, new_results, { luanil = { object = true } })

if not ok or not parsed.testResults then
return {}
end

return parsed_json_to_results(parsed, results_path, nil)
end
end,
Expand Down

0 comments on commit 8037c33

Please sign in to comment.