Open lucax88x opened 4 months ago
nvm, just checked readme:
test.each is currently not well supported (WIP)
I confirm, currently this adapter does not support test.each. AFAIK there isn't an afforbable solution leveraging only treesitter. I believe that we can enhance the test discovery once we have 'vitest list' https://github.com/vitest-dev/vitest/pull/4240
Ah, I forked it because i wanted to try to fix it.
But neotest-jest works for that, do they have the list
already?
Hi @lucax88x! That would be great! I tested the neotest-jest functionality some time ago, and it seemed to not be working properly. However, they may have fixed this since then, so we can take inspiration from their implementation
Hey 👋🏾
Jumping straight into the conversation. Would it be feasible to start with a simple solution where it is possible to run just the "whole" test.each test case? I guess there could be little function which takes a test description and replaces template sequences with globs? Like for example it.each([1, 2, 3])("should fail for %d", () => { /* ... */ })
could be executed with the stupid simple --testNamePattern='should fail for .*'
argument. That's not optimal, but would a first solution that allows users to execute these tests somehow. Not sure if this is not worth the effort because work on the proper solution is almost done.
Not sure if this is not worth the effort because work on the proper solution is almost done.
@weilbith can you point me to where this work is currently on going so I can track and see if I can help out at all? Thanks!
fyi @marilari88 @lucax88x Vitest finally landed (v2.0) the vitest list
cli api that was mentioned above. See here: https://github.com/vitest-dev/vitest/releases/tag/v2.0.0
Here are the docs for vitest list: https://vitest.dev/guide/cli#vitest-list
This is how the vitest-jest plugin handles it.each "parameterized" tests. Their PR for the feature here (lots of details and discussion): https://github.com/nvim-neotest/neotest-jest/pull/51
Btw for anyone that is still trying to tackle this PR (I cannot as do not have time right now and am too uneducated on the neotest adapter "internals" etc.) ... here is roughly what you need (I confirmed this code below works and returns the test names) for using the new vitest list command to get all the test names (and variations with it.each) from a give path.
This is related to what neotest-jest implemented here and here and is the comparable way to get the test names like how they do it running the jest cli.
local binary = vitest_util.getVitestCommand(file_path)
local command = vim.split(binary, "%s+")
vim.list_extend(command, {
"list",
"--json",
"--dir",
file_path,
})
local result = { lib.process.run(command, { stdout = true }) }
Hope this helps!
Hi @GitMurf , I came from this issue: https://github.com/marilari88/neotest-vitest/issues/48, I would like to know if the problem you mentioned in the issue is solved? How is it solved? I have the same problem as you.
@Daydreamer-riri since this is a different issue (related to running template ".each()" tests) lets discuss in the other Issue... I just responded to you there.
Looks like this is not supported, am I right?
They looks to be "listed" in the output, but not in the summary and they're always "skipped".