sidlatau / neotest-dart

30 stars 8 forks source link

Issue with recognizing a test #2

Closed Chaitanyabsprip closed 1 year ago

Chaitanyabsprip commented 1 year ago
test(
   'should return true when isRegistered is called with registered '
   'service', () {
        appEventService.registerEventService(FakeEventService(), events: []);
        expect(appEventService.isRegistered<FakeEventService>(), true);
});

The kind of tests that have the description too long are not recognized by neotest-dart

sidlatau commented 1 year ago

Hmm, looks like treesitter is not enough to handle all edge cases when constructing test names. I see Dart Code uses LSP outline information to construct these names (https://github.com/Dart-Code/Dart-Code/blob/c056a71922918fff527726826fa12de7d0fa996a/src/shared/utils/outline_lsp.ts). I will investigate if it is possible to use this information here.

The quick workaround would be to use triple quotes:

test(
   '''should return true when isRegistered is called with registered 
   service''', () {
        appEventService.registerEventService(FakeEventService(), events: []);
        expect(appEventService.isRegistered<FakeEventService>(), true);
});
sidlatau commented 1 year ago

I added the ability to use LSP information. @Chaitanyabsprip, you may try it using this config: Packer:

    use {
      "sidlatau/neotest-dart",
      branch="lsp"
    }

Adapter config:

require("neotest").setup {
  adapters = {
    require "neotest-dart" {
      command = ...
      use_lsp = true,
    },
  },
}

With LSP there is some delay until outline information is available. So if the test is started before the outline is available, the test will not be found. Not sure how to solve it. But maybe it is not a problem?

Chaitanyabsprip commented 1 year ago

will test and get back to you

and for the delay, could you make a variable that shows whether it's ready or a method that's async and only completes when the outline is ready. This way the user can work around the delay