Skip to content

Commit

Permalink
Merge branch 'main' into windows_support
Browse files Browse the repository at this point in the history
  • Loading branch information
Pineappletooth committed Dec 18, 2023
2 parents ec1d37d + a394106 commit 48c60b1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 nvim-neotest

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use({
'nvim-neotest/neotest',
requires = {
...,
'haydenmeade/neotest-jest',
'nvim-neotest/neotest-jest',
}
config = function()
require('neotest').setup({
Expand Down Expand Up @@ -54,7 +54,7 @@ require('neotest').setup({
...,
adapters = {
require('neotest-jest')({
jestCommand = "jest --watch ",
jestCommand = require('neotest-jest.jest-util').getJestCommand(vim.fn.expand '%:p:h') .. ' --watch',
}),
}
})
Expand Down
3 changes: 2 additions & 1 deletion lua/neotest-jest/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function adapter.is_test_file(file_path)
is_test_file = true
end

for _, x in ipairs({ "spec", "test", "unit", "regression", "integration" }) do
for _, x in ipairs({ "spec", "e2e%-spec", "test", "unit", "regression", "integration" }) do
for _, ext in ipairs({ "js", "jsx", "coffee", "ts", "tsx" }) do
if string.match(file_path, "%." .. x .. "%." .. ext .. "$") then
is_test_file = true
Expand Down Expand Up @@ -416,6 +416,7 @@ function adapter.build_spec(args)
"--json",
"--outputFile=" .. results_path,
"--testNamePattern=" .. testNamePattern,
"--forceExit",
vim.fs.normalize(pos.path),
})

Expand Down
20 changes: 20 additions & 0 deletions tests/init_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,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()

Expand Down

0 comments on commit 48c60b1

Please sign in to comment.