-
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
Doesn't support it.each tests #2
Comments
I've already investigated this. We need first |
Wondering if we can build string formatted test names in adapter.discover_positions(path). |
Could you provide an example of string formatted test names? |
Not at pc right now, but https://jestjs.io/docs/api#testeachtablename-fn-timeout
|
See #21 for unit test.
I prefer the 1st option since you would see the correct names in the test sidebar. |
Yep. This implies implementing the Jest interpolation logic by ourselves in the parsing method, but I don't see any other valid way... |
I'm taking a look at the code and we need to change the treesitter lib of neotest. Something like this: diff --git a/lua/neotest/lib/treesitter/init.lua b/lua/neotest/lib/treesitter/init.lua
index 26b7e8c..8b44f6a 100644
--- a/lua/neotest/lib/treesitter/init.lua
+++ b/lua/neotest/lib/treesitter/init.lua
@@ -40,11 +40,13 @@ local function collect(file_path, query, source, root)
---@type string
local name = vim.treesitter.get_node_text(match[query.captures[type .. ".name"]], source)
local definition = match[query.captures[type .. ".definition"]]
+ local args = match[query.captures[type .. ".args"]]
nodes:push({
type = type,
path = file_path,
name = name,
+ args = args and vim.treesitter.get_node_text(args, source) or nil,
range = { definition:range() },
})
end Then we can use it with this query ; Matches: `test.each(['data'])('test') / it.each(['data'])('test')`
((call_expression
function: (call_expression
function: (member_expression
object: (identifier) @func_name (#any-of? @func_name "it" "test")
)
arguments: (arguments (_) @test.args)
)
arguments: (arguments (string (string_fragment) @test.name) (arrow_function))
)) @test.definition
We also need to implement something in neotest to create multiple test node using one single node... |
Sounds like a reasonable approach to me |
Is there any news about this issue? Its one of the featured that is used over the place, and not to be able to run this kind a tests is a big con. |
There were a few solutions proposed in nvim-neotest/neotest#68. I haven't had time to look into it, but it would be great if someone could :) |
Hey!
At first I've tried to go with the first approach, because treesitter compared with it.each([SomeEnum.Value])('should allow number values %s', (param) => {
expect(number).toBe(1);
});
it.each(someImportedData)('should allow number values %s', (param) => {
expect(number).toBe(1);
}); we could't even guess number of tests - this prevents us from connecting the tests by their order in tests results. Therefore I went with second approach and I would like to know your opinion on this. This is the algorithm that I went for in my PR (#51):
With this approach we are certain to have correct every test name in the summary window. I've linked a WIP PR to see what do you think about this approach. Ad. 1 |
@KostkaBrukowa very interested in where you're up to with this. Would be happy to help if you don't have time to address the bugs mentioned in here #51 |
Sorry for late replies. I've replied in the PR, but unfortunately I'm no longer working with |
it.each([...])(...)
The text was updated successfully, but these errors were encountered: