From 71d7e660ebb0954578fe8f21f16dc319cc945b21 Mon Sep 17 00:00:00 2001 From: Andy Boyd <31546234+StephenABoyd@users.noreply.github.com> Date: Mon, 31 Jul 2023 20:21:39 +0000 Subject: [PATCH] Use args.jestCommand if exists as an override --- lua/neotest-jest/init.lua | 2 +- tests/init_spec.lua | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lua/neotest-jest/init.lua b/lua/neotest-jest/init.lua index 57a7972..ba6b246 100644 --- a/lua/neotest-jest/init.lua +++ b/lua/neotest-jest/init.lua @@ -370,7 +370,7 @@ function adapter.build_spec(args) end end - local binary = getJestCommand(pos.path) + local binary = args.jestCommand or getJestCommand(pos.path) local config = getJestConfig(pos.path) or "jest.config.js" local command = vim.split(binary, "%s+") if util.path.exists(config) then diff --git a/tests/init_spec.lua b/tests/init_spec.lua index b43b9e2..f21ac1c 100644 --- a/tests/init_spec.lua +++ b/tests/init_spec.lua @@ -143,6 +143,26 @@ describe("build_spec", function() assert.is.truthy(spec.context.results_path) end) + async.it("builds command for file test with jestCommand arg", function() + local positions = plugin.discover_positions("./spec/basic.test.ts"):to_list() + local tree = Tree.from_list(positions, function(pos) + return pos.id + end) + local spec = plugin.build_spec({ tree = tree, jestCommand = 'jest --watch ' }) + + assert.is.truthy(spec) + local command = spec.command + assert.is.truthy(command) + assert.contains(command, "jest") + assert.contains(command, "--watch") + assert.contains(command, "--json") + assert.is_not.contains(command, "--config=jest.config.js") + assert.contains(command, "--testNamePattern='.*'") + assert.contains(command, "./spec/basic.test.ts") + assert.is.truthy(spec.context.file) + assert.is.truthy(spec.context.results_path) + end) + async.it("builds command for namespace", function() local positions = plugin.discover_positions("./spec/basic.test.ts"):to_list()