From 375d20a6d1cf4ef9fd336ba83d9bee2fd971404d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Mon, 9 Jan 2023 23:03:57 +0000 Subject: [PATCH] Add support for file path patterns --- lua/neotest-jest/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/neotest-jest/init.lua b/lua/neotest-jest/init.lua index ac6a08e..27908e3 100644 --- a/lua/neotest-jest/init.lua +++ b/lua/neotest-jest/init.lua @@ -278,6 +278,8 @@ function adapter.build_spec(args) else testNamePattern = testNamePattern .. "'" end + elseif pos.type == "file" then + testNamePattern = pos.name end local binary = getJestCommand(pos.path) @@ -288,13 +290,15 @@ function adapter.build_spec(args) table.insert(command, "--config=" .. config) end + local testPattern = pos.type == "file" and '--testPathPattern=' or '--testNamePattern=' + vim.list_extend(command, { "--no-coverage", "--testLocationInResults", "--verbose", "--json", "--outputFile=" .. results_path, - "--testNamePattern=" .. testNamePattern, + testPattern .. testNamePattern, pos.path, })