add configurable glob test pattern for TSamAll

This commit is contained in:
2026-01-06 16:20:15 +01:00
parent f3350cad98
commit 2d5889dce3
3 changed files with 42 additions and 3 deletions

View File

@@ -24,6 +24,10 @@ local function with_project(structure, fn)
end
describe("test-samurai-mocha-runner", function()
before_each(function()
runner.setup()
end)
it("detects mocha test files via package.json", function()
with_project({
["package.json"] = [[{"devDependencies":{"mocha":"10.0.0"}}]],
@@ -170,7 +174,18 @@ describe("test-samurai-mocha-runner", function()
}, function(root)
local bufnr = make_buffer(root .. "/test/sample.spec.js", "")
local command = runner.build_all_command(bufnr)
assert.is_true(vim.tbl_contains(command.cmd, "test/**/*.{test,spec}.{t,j}s"))
assert.is_true(vim.tbl_contains(command.cmd, "test/**/*.test.js"))
end)
end)
it("allows overriding the TSamAll test glob via setup", function()
with_project({
["package.json"] = [[{"devDependencies":{"mocha":"10.0.0"}}]],
}, function(root)
runner.setup({ all_test_glob = "spec/**/*_spec.js" })
local bufnr = make_buffer(root .. "/test/sample.spec.js", "")
local command = runner.build_all_command(bufnr)
assert.is_true(vim.tbl_contains(command.cmd, "spec/**/*_spec.js"))
end)
end)