Open h0adp0re opened 1 year ago
Hi @h0adp0re! I tried to repro your case and everything works fine (as you can see in the picture below). Can you tell me if you are experiencing any problems discovering the tests or running them? Do you see the tests in the summary panel? The order in which the adapter checks for the existence of the tests folder should not affect the result of the is_test_file function.
Hey, that's strange. I found that after saving the file once, everything works as expected, but only for that file.
Everything works as expected globally when I delete the __tests__
directory from root. 🤷♂️
But, let's pretend I don't save the file first nor delete anything. The summary panel actually does show 2 directories — __tests__
and src
.
require("neotest").run.run()
doesn't seem to do anything, although the editor slows down a bit for a few seconds; something must be happening in the background.summary.mappings.run
) results in:
require("neotest").run.run()
works as expected.Sounds like some initialization or perhaps an autocommand problem on my side?
Edit: I tried to make the text more structured, hope it's not too confusing.
Alright well, thanks @AlexandrosAlexiou! #43 helped fix this issue for me. I simply told neotest-vitest
to only consider what it finds in the src
folder as tests in my special project.
Although I would like to confirm that I'm using this correctly. Is the true
default sensible?
adapters = {
require("neotest-vitest")({
is_test_file = function(file_path)
if string.match(file_path, "my-project") then
return string.match(file_path, "/src/")
end
return true
end,
}),
},
And more, reading the source suggests that this check runs in addition to the usual checks? Would moving this condition as the first one in the routine save some needless parsing in unrelated directories? https://github.com/marilari88/neotest-vitest/blob/c0ea475596483eb02fa8e92c6be65c0536d55630/lua/neotest-vitest/init.lua#L430-L435
We have a
__tests__
folder in the root of our project for legacy reasons and the actual tests for our components are in the components' sub-folders withinsrc
. How to proceed?Edit: you should probably check whether the filename contains
spec
ortest
before checking whether the file is in__tests__
.