You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all I appreciate this is a bit of a niche configuration but wanted to raise an issue to see if anyone had any advice for fixing it as I tried looking into it but was unsuccessful.
In a project I work in, we have a series of tests that test different API endpoints and in these test suites we have multiple describe blocks, one of which is returned from a function that conditionally runs tests (see example below). The issue is that as far as I can tell treesitter will only parse the text in the file itself, it won't evaluate any functions in the file to see what they return and whether that can be a test or not which leads to tests being missed in the discovery window / test statuses in the gutter.
Example implementation below:
// foo.test.jsimport{functionReturnsTests}from'./test-generator.js';describe('Foo Test',()=>{describe('Describe One',()=>{it('runs some test',()=>{});});functionReturnsTests({runTestOne: true,runTestTwo: false});}
// test-generator.jsfunctiontestOne(){returnit('runs a test',()=>{});}functiontestTwo(){returnit('runs a second test',()=>{});}exportfunctionfunctionReturnsTests({runTestOne, runTestTwo}){returndescribe('Describe Two',()=>{if(runTestOne)testOne();if(runTestTwo)testTwo();});}
In this example I would expect the discovery panel to look like the below.
- foo.test.js
- Foo Test
- Describe One
- runs some test
- Describe Two
- runs a test
But at the moment I'm only seeing the below.
- foo.test.js
- Foo Test
- Describe One
- runs some test
As mentioned I did some digging into this to try see what the issue could be and found that the tests are being run by neotest as when I checked the output files in the var directory I could see the results of the tests from the imported function. These tests are also correctly found by the jest CLI which is why I imagine they run correctly through neotest so it appears the issue is just in the project summary / discovery as well as in the pass/fail/in-progress symbols in the gutter.
It's worth noting that these tests are correctly identified and ran with status symbols in VSCode with the Jest extension so I believe this issue is related to neotest.
Someone more experienced with Neovim/treesitter might have a better idea of how to fix this but my original thinking was to somehow build the tests file out into a single file that contains all of the imported code and then run treesitter against that to correctly identify the imported code but I imagine this could get quite time consuming / costly when run at scale which isn't ideal.
The text was updated successfully, but these errors were encountered:
First of all I appreciate this is a bit of a niche configuration but wanted to raise an issue to see if anyone had any advice for fixing it as I tried looking into it but was unsuccessful.
In a project I work in, we have a series of tests that test different API endpoints and in these test suites we have multiple describe blocks, one of which is returned from a function that conditionally runs tests (see example below). The issue is that as far as I can tell treesitter will only parse the text in the file itself, it won't evaluate any functions in the file to see what they return and whether that can be a test or not which leads to tests being missed in the discovery window / test statuses in the gutter.
Example implementation below:
In this example I would expect the discovery panel to look like the below.
But at the moment I'm only seeing the below.
As mentioned I did some digging into this to try see what the issue could be and found that the tests are being run by
neotest
as when I checked the output files in thevar
directory I could see the results of the tests from the imported function. These tests are also correctly found by the jest CLI which is why I imagine they run correctly throughneotest
so it appears the issue is just in the project summary / discovery as well as in the pass/fail/in-progress symbols in the gutter.It's worth noting that these tests are correctly identified and ran with status symbols in VSCode with the Jest extension so I believe this issue is related to
neotest
.Someone more experienced with Neovim/treesitter might have a better idea of how to fix this but my original thinking was to somehow build the tests file out into a single file that contains all of the imported code and then run treesitter against that to correctly identify the imported code but I imagine this could get quite time consuming / costly when run at scale which isn't ideal.
The text was updated successfully, but these errors were encountered: