adrigzr / neotest-mocha

Neotest runner for Mocha test framework
10 stars 9 forks source link

Uniquely identify tests #13

Closed MisanthropicBit closed 8 months ago

MisanthropicBit commented 9 months ago

With the current implementation, running the test in either suite 1 or suite 2 will run the other test as well because the pattern that is constructed and passed to mocha doesn't account for the suite name.

describe('top-level suite', () => {
  describe('suite 1', () => {
    it('tests a test', async () => {
      console.log("first test")
    })
  })
  describe('suite 2', () => {
    it('tests a test', async () => {
      console.log("second test")
    })
  })
})

These changes follow the code in neotest-jest with some modification. Hopefully the code and test are straight-forward.

Failing test is related to neotest's treesitter module.

adrigzr commented 9 months ago

Hi @MisanthropicBit, thanks for your PR! Could you take a look at the failing jobs? 🙏

MisanthropicBit commented 9 months ago

I had some time to look at the issue which stems from this neotest PR which changes the failing line. It is listed as a breaking change that requires at least neovim 0.9.0 (as seen from the release notes) which is why the test fails with 0.7.0.

Options would be:

This isn't technically a blocker for this PR since it has nothing to do with my changes, just that neotest got updated meanwhile, but we might as well fix it now 🙂

MisanthropicBit commented 8 months ago

I've removed the 0.7.0 test from the workflow and added a note about requiring at least neotest 4.0.0.

Now the tests against nightly fail, likely because something happened with treesitter upstream. I've verified that the query works with :TSPlaygroundToggle (on 0.9.0) so I'll try to see what changed (if this is intentional) or if it's a bug in nightly when I have some more time.

MisanthropicBit commented 8 months ago

@adrigzr So I think I figured out the issue:

I've updated the discover_positions function to use function_expression instead which solves the issue but this is an issue for users that don't have nvim-treesitter >= 0.9.2 so perhaps the query should be conditional on the nvim-treesitter version?

adrigzr commented 8 months ago

Hello @MisanthropicBit, the change looks good to me. I'm merging it with the main branch. Thanks a lot!