-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for parameterized tests #51
Merged
haydenmeade
merged 19 commits into
nvim-neotest:main
from
KostkaBrukowa:parameterized-tests-final
Nov 13, 2023
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
607788c
Adds support for parameterized it.each
KostkaBrukowa d524764
Removes unnecessary TS query
KostkaBrukowa 8e58dbc
parameterized-tests | Checks for range instead of precise position wh…
KostkaBrukowa 67e4231
parameterized-tests | Adds comments to all new functions
KostkaBrukowa 44ce317
parameterized-tests | Removes debug imports
KostkaBrukowa 51eaaea
parameterized-tests | Fixes import
KostkaBrukowa 691c07a
Merge remote-tracking branch 'origin/main' into parameterized-tests-f…
KostkaBrukowa f8dadc5
Adds support for running parameterized tests
KostkaBrukowa 9756101
Merge branch 'main' into parameterized-tests-final
KostkaBrukowa 379d7db
Merges with main
KostkaBrukowa de69cd7
parameterized-tests | Fixes jest watch
KostkaBrukowa 247d0bd
Adds README
KostkaBrukowa 6a172cb
Small refactor
KostkaBrukowa 7440d5a
Minor speedup when running discovery
KostkaBrukowa bdb8a0e
parameterized-tests | Removes speedup because it breaks some tests
KostkaBrukowa a7dd25d
removes unused file
KostkaBrukowa 967cc77
Merge branch 'main' into parameterized-tests-final
KostkaBrukowa ebed0db
Merge branch 'main' into parameterized-tests-final
KostkaBrukowa e995de0
fix: stylua
KostkaBrukowa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
local util = require("neotest-jest.util") | ||
|
||
local M = {} | ||
|
||
function M.is_callable(obj) | ||
return type(obj) == "function" or (type(obj) == "table" and obj.__call) | ||
end | ||
|
||
-- Returns jest binary from `node_modules` if that binary exists and `jest` otherwise. | ||
---@param path string | ||
---@return string | ||
function M.getJestCommand(path) | ||
local gitAncestor = util.find_git_ancestor(path) | ||
|
||
local function findBinary(p) | ||
local rootPath = util.find_node_modules_ancestor(p) | ||
local jestBinary = util.path.join(rootPath, "node_modules", ".bin", "jest") | ||
|
||
if util.path.exists(jestBinary) then | ||
return jestBinary | ||
end | ||
|
||
-- If no binary found and the current directory isn't the parent | ||
-- git ancestor, let's traverse up the tree again | ||
if rootPath ~= gitAncestor then | ||
return findBinary(util.path.dirname(rootPath)) | ||
end | ||
end | ||
|
||
local foundBinary = findBinary(path) | ||
|
||
if foundBinary then | ||
return foundBinary | ||
end | ||
|
||
return "jest" | ||
end | ||
|
||
local jestConfigPattern = util.root_pattern("jest.config.{js,ts}") | ||
|
||
-- Returns jest config file path if it exists. | ||
---@param path string | ||
---@return string|nil | ||
function M.getJestConfig(path) | ||
local rootPath = jestConfigPattern(path) | ||
|
||
if not rootPath then | ||
return nil | ||
end | ||
|
||
local jestJs = util.path.join(rootPath, "jest.config.js") | ||
local jestTs = util.path.join(rootPath, "jest.config.ts") | ||
|
||
if util.path.exists(jestTs) then | ||
return jestTs | ||
end | ||
|
||
return jestJs | ||
end | ||
|
||
-- Returns neotest test id from jest test result. | ||
-- @param testFile string | ||
-- @param assertionResult table | ||
-- @return string | ||
function M.get_test_full_id_from_test_result(testFile, assertionResult) | ||
local keyid = testFile | ||
local name = assertionResult.title | ||
|
||
for _, value in ipairs(assertionResult.ancestorTitles) do | ||
keyid = keyid .. "::" .. value | ||
end | ||
|
||
keyid = keyid .. "::" .. name | ||
|
||
return keyid | ||
end | ||
|
||
return M |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
acutally I meant to use
false
here, because if someone does not diablediscovery
key and automatically will update the plugin, this option will run jest commands on all of the files in the project. I think that this solution should be opt-inThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but wouldn't it be misleading if the e.g. for enabling the discovery displayed the value as false?