local test_samurai = require("test-samurai") local core = require("test-samurai.core") local function close_output_container() local keys = vim.api.nvim_replace_termcodes("", true, false, true) local attempts = 5 while attempts > 0 do local float_win = nil for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do local cfg = vim.api.nvim_win_get_config(win) if cfg.relative ~= "" then float_win = win break end end if not float_win then break end vim.api.nvim_set_current_win(float_win) vim.api.nvim_feedkeys(keys, "x", false) vim.wait(20, function() for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do local cfg = vim.api.nvim_win_get_config(win) if cfg.relative ~= "" then return false end end return true end) attempts = attempts - 1 end end local function stub_jobstart(opts_config) local orig = vim.fn.jobstart local config = opts_config or {} vim.fn.jobstart = function(_cmd, opts) local out = config.stdout or nil if out and opts and opts.on_stdout then if type(out) == "string" then out = { out } end opts.on_stdout(1, out, nil) end if opts and opts.on_exit then opts.on_exit(1, config.exit_code or 0, nil) end return 1 end return orig end describe("test-samurai quickfix (vitest)", function() before_each(function() test_samurai.setup() end) after_each(function() close_output_container() vim.fn.setqflist({}, "r") end) it("mappt tap-flat Failures mit >-Trenner auf die Testzeile", function() local root = vim.fs.joinpath(vim.loop.cwd(), "tests", "tmp_qf_vitest") vim.fn.mkdir(root, "p") local path = root .. "/foo_qf.test.ts" local pkg = root .. "/package.json" vim.fn.writefile({ "{", ' "devDependencies": { "vitest": "^1.0.0" }', "}", }, pkg) vim.fn.writefile({ 'describe("outer", function() {', ' it("inner 1", function() {', " })", "", ' it("inner 2", function() {', " })", "})", }, path) local bufnr = vim.api.nvim_create_buf(false, true) vim.api.nvim_buf_set_name(bufnr, path) vim.bo[bufnr].filetype = "typescript" vim.api.nvim_set_current_buf(bufnr) local orig_jobstart = stub_jobstart({ exit_code = 1, stdout = { "not ok 1 - outer > inner 2 # time=12.3ms" }, }) core.run_file() local qf = vim.fn.getqflist() assert.equals(1, #qf) assert.equals(path, vim.fn.bufname(qf[1].bufnr)) assert.equals(5, qf[1].lnum) vim.fn.jobstart = orig_jobstart end) end)