detect and use project jest.setup.{j,t}s files
All checks were successful
tests / test (push) Successful in 8s
All checks were successful
tests / test (push) Successful in 8s
This commit is contained in:
@@ -279,6 +279,62 @@ describe("test-samurai-jest-runner", function()
|
||||
end)
|
||||
end)
|
||||
|
||||
it("adds jest.setup.js from project root to setupFilesAfterEnv", function()
|
||||
with_project(JEST_PACKAGE, function(root)
|
||||
write_file(root .. "/jest.setup.js", "console.log('setup')")
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_name(bufnr, root .. "/foo.test.ts")
|
||||
|
||||
local cmd_spec = runner.build_file_command(bufnr)
|
||||
|
||||
assert.are.same(
|
||||
{
|
||||
"npx",
|
||||
"jest",
|
||||
"--testLocationInResults",
|
||||
"--reporters",
|
||||
get_reporter_path(),
|
||||
"--setupFilesAfterEnv",
|
||||
get_setup_path(),
|
||||
"--setupFilesAfterEnv",
|
||||
root .. "/jest.setup.js",
|
||||
"--runTestsByPath",
|
||||
root .. "/foo.test.ts",
|
||||
},
|
||||
cmd_spec.cmd
|
||||
)
|
||||
assert.equals(root, cmd_spec.cwd)
|
||||
end)
|
||||
end)
|
||||
|
||||
it("adds jest.setup.ts from test/.bin when root setup is missing", function()
|
||||
with_project(JEST_PACKAGE, function(root)
|
||||
write_file(root .. "/test/.bin/jest.setup.ts", "console.log('setup')")
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_name(bufnr, root .. "/bar.test.ts")
|
||||
|
||||
local cmd_spec = runner.build_file_command(bufnr)
|
||||
|
||||
assert.are.same(
|
||||
{
|
||||
"npx",
|
||||
"jest",
|
||||
"--testLocationInResults",
|
||||
"--reporters",
|
||||
get_reporter_path(),
|
||||
"--setupFilesAfterEnv",
|
||||
get_setup_path(),
|
||||
"--setupFilesAfterEnv",
|
||||
root .. "/test/.bin/jest.setup.ts",
|
||||
"--runTestsByPath",
|
||||
root .. "/bar.test.ts",
|
||||
},
|
||||
cmd_spec.cmd
|
||||
)
|
||||
assert.equals(root, cmd_spec.cwd)
|
||||
end)
|
||||
end)
|
||||
|
||||
it("build_all_command runs project tests", function()
|
||||
with_project(JEST_PACKAGE, function(root)
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
|
||||
Reference in New Issue
Block a user