Git Product home page Git Product logo

neotest-dart's People

Contributors

hecatoncheir avatar huylg avatar mikeborodin avatar sidlatau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

neotest-dart's Issues

Watch for changes

Hi, the plugin works nicely for me, however, I wonder why it does not seem to work when I mark a file or directory to be watched. When I then saved the file, nothing happened. Is this something that needs to be supported by the neotest adapter and is not implemented yet?

adapter root can be wrong if a folder named dart is in the tree

nvim-neotest/neotest#237

adapter.root = lib.files.match_root_pattern('dart')
this line sets the root to the first it meets with the name dart. I have a folder in my path to the project named dart and it will then be set as the root.

Is there a particular reason for this?

I checked the adapter for go and they use the following to set the root. Would it be enough to use pubspec.yaml or something similar for Dart as a more robust way of setting this?
adapter.root = lib.files.match_root_pattern("go.mod", "go.sum")

Not quite sure how this lib.files.match_root_pattern works though. When i renamed my dart folder the root was set correctly.

Cannot recognize blocTests

This plugin won't recognize blocTest, f.e this one:

    blocTest<AuthBloc, AuthState>(
      '''
SHOULD emit [AuthState] authenticated after AuthenticationStatus changed to authenticated
      ''',
      build: () => authBloc,
      act: (bloc) => ...,
      expect: () => [
        ...
      ],
    );

I am wondering whether this could easily be fix by adding blocTest to line13 in file lsp_outline_parser.lua ?

 local _, _, test_name = element.name:find('[testWidgets,test, blocTest]%("(.+)"%)')

Can't get plugin to work with lazyvim

Hey,

This is probably not an issue with the plugin, but any help you can provide would be appreciated :) I am new to Neovim and trying to set up Flutter with lazyvim. I have got the status sidebar to display files with tests but it does not seem to pick up individual test, likewise if I put my curser in a test and try to run I get a notice 'no tests found'.

I followed this guide to get set-up: https://www.lazyvim.org/extras/test/core, I managed to get Go tests working so I think the core-set up is OK. I have tried various combinations but this is what the plugin file currently looks like:

{
    "nvim-neotest/neotest",
    dependencies = {
      "sidlatau/neotest-dart",
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter",
    },
    opts = {
      adaters = {
        ["neotest-dart"] = {
          command = "flutter",
          use_lsp = true,
        },
      },
    },
  },

Any ideas what could be going wrong?

Thanks

Issue with recognizing a test

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

Not working for widget tests

image

when I run `require('neotest').run.run()` on this test, I get a notification saying `no tests found`.

however when I run the tests from the summary window, I get the following output

image

{"protocolVersion":"0.1.1","runnerVersion":null,"pid":72629,"type":"start","time":0}
{"suite":{"id":0,"platform":"vm","path":"/Users/chaitanyasharma/Projects/ApplicationDevelopment/minesweeper/test/pages/game_menu_test.dart"},"type":"suite","time":0}
{"test":{"id":1,"name":"loading /Users/chaitanyasharma/Projects/ApplicationDevelopment/minesweeper/test/pages/game_menu_test.dart","suiteID":0,"groupIDs":[],"metadat
a":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":0}
{"count":1,"time":3,"type":"allSuites"}
{"testID":1,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":1757}
{"group":{"id":2,"suiteID":0,"parentID":null,"name":"","metadata":{"skip":false,"skipReason":null},"testCount":1,"line":null,"column":null,"url":null},"type":"group"
,"time":1758}
{"group":{"id":3,"suiteID":0,"parentID":2,"name":"menu","metadata":{"skip":false,"skipReason":null},"testCount":1,"line":6,"column":3,"url":"file:///Users/chaitanyas
harma/Projects/ApplicationDevelopment/minesweeper/test/pages/game_menu_test.dart"},"type":"group","time":1759}
{"test":{"id":4,"name":"menu should show new game button","suiteID":0,"groupIDs":[2,3],"metadata":{"skip":false,"skipReason":null},"line":154,"column":5,"url":"packa
ge:flutter_test/src/widget_tester.dart","root_line":7,"root_column":5,"root_url":"file:///Users/chaitanyasharma/Projects/ApplicationDevelopment/minesweeper/test/page
s/game_menu_test.dart"},"type":"testStart","time":1759}
{"testID":4,"result":"success","skipped":false,"hidden":false,"type":"testDone","time":2649}
{"success":true,"type":"done","time":2667}

Unable to debug flutter test

When trying to debug test the following error is being thrown

neotest-dart: ...al/AppData/Local/nvim-data/lazy/neotest/lua/nio/init.lua:105: The coroutine failed with this message: ...AppData/Local/nvim-data/lazy/neotest/lua/nio/control.lua:208: ...ppData/Local/nvim-data/lazy/nvim-dap/lua/dap/session.lua:1420: Error running flutter: ENOENT: no such file or directory stack traceback: [C]: in function 'error' ...AppData/Local/nvim-data/lazy/neotest/lua/nio/control.lua:208: in function 'with' ...data/lazy/neotest/lua/neotest/client/strategies/init.lua:37: in function 'run' ...cal/nvim-data/lazy/neotest/lua/neotest/client/runner.lua:129: in function '_run_spec' ...cal/nvim-data/lazy/neotest/lua/neotest/client/runner.lua:89: in function <...cal/nvim-data/lazy/neotest/lua/neotest/client/runner.lua:88>

The test's are running without any issues when not debugging

This is my neotest config file

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

this is my dap configuration for flutter

`local dap = require('dap')
local dapui = require('dapui')

dap.adapters.dart = {
type = 'executable',
command = vim.fn.stdpath('data') .. '/mason/bin/dart-debug-adapter.cmd',
args = { 'flutter' },
options = {
detached = false,
},
}

dap.configurations.dart = {
{
type = "flutter",
request = "launch",
name = "Launch flutter",
dartSdkPath = "C:/src/flutter/bin/cache/dart-sdk/",
flutterSdkPath = "C:/src/flutter/",
program = "${workspaceFolder}/lib/main.dart",
cwd = "${workspaceFolder}",
console = 'externalTerminal',
},
{
type = 'flutter',
request = 'attach',
name = 'Attach Program',
dartSdkPath = "C:/src/flutter/bin/cache/dart-sdk/",
flutterSdkPath = "C:/src/flutter/",
program = "${workspaceFolder}/lib/main.dart",
cwd = "${workspaceFolder}",
console = 'externalTerminal',
}
}`

And this is my config file for flutter-tools.nvim

`local flutter = require('flutter-tools')

-- alternatively you can override the default configs
flutter.setup {
ui = {
-- the border type to use for all floating windows, the same options/formats
-- used for ":h nvim_open_win" e.g. "single" | "shadow" | {}
border = "rounded",
-- This determines whether notifications are show with vim.notify or with the plugin's custom UI
-- please note that this option is eventually going to be deprecated and users will need to
-- depend on plugins like nvim-notify instead.
notification_style = 'plugin'
},
decorations = {
statusline = {
-- set to true to be able use the 'flutter_tools_decorations.app_version' in your statusline
-- this will show the current version of the flutter app from the pubspec.yaml file
app_version = true,
-- set to true to be able use the 'flutter_tools_decorations.device' in your statusline
-- this will show the currently running device if an application was started with a specific
-- device
device = true,
-- set to true to be able use the 'flutter_tools_decorations.project_config' in your statusline
-- this will show the currently selected project configuration
project_config = true,
}
},
debugger = { -- integrate with nvim dap + install dart code debugger
enabled = false,
run_via_dap = true, -- use dap instead of a plenary job to run flutter apps
-- if empty dap will not stop on any exceptions, otherwise it will stop on those specified
-- see |:help dap.set_exception_breakpoints()| for more info
exception_breakpoints = {}
},
flutter_path = "C:/src/flutter/bin/flutter.bat", -- <-- this takes priority over the lookup
fvm = false, -- takes priority over path, uses /.fvm/flutter_sdk if enabled
widget_guides = {
enabled = true,
},
dev_log = {
enabled = true,
notify_errors = false, -- if there is an error whilst running then notify the user
open_cmd = "tabnew", -- command to use to open the log buffer
},
dev_tools = {
autostart = true, -- autostart devtools server if not detected
auto_open_browser = false, -- Automatically opens devtools in the browser
},
outline = {
open_cmd = "30vnew", -- command to use to open the outline buffer
auto_open = false -- if true this will open the outline automatically when it is first populated
},
lsp = {
color = { -- show the derived colours for dart variables
enabled = true, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
background = true, -- highlight the background
background_color = { r = 19, g = 17, b = 24 }, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
foreground = false, -- highlight the foreground
virtual_text = true, -- show the highlight using virtual text
-- virtual_text_str = "■", -- the virtual text character to highlight
},
on_attach = on_attach,
capabilities = capabilities, -- e.g. lsp_status capabilities
-- see the link below for details on each option:
-- https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration
settings = {
showTodos = true,
completeFunctionCalls = true,
analysisExcludedFolders = { "C:/Users/nihal/AppData/Local/Pub/Cache"--[[ , "C:/src/flutter", ]] },
renameFilesWithClasses = "prompt", -- "always"
enableSnippets = true,
updateImportsOnRename = true, -- Whether to update imports and other directives when files are renamed. Required for FlutterRename command.
}
}
}`

Reduce usage of Treesitter

Related to #7

We are now relying on Treesitter to get test positions. But the LSP outline event has the more correct information about test names and positions, so we should prefer that info. That would also solve an issue with custom test names, no config in this plugin would be required.

One more possible additional improvement - use position to run tests: https://dartcode.org/releases/#testing-improvements

dart test "test/foo_test.dart?line=4"

Unable to run tests for entire suite

Hello,

I'm using neotest-dart with flutter-tools.nvim for a few months now, everything works great when I'm working with tests in a single file.
However when I try to run tests for entire suite, tests immediately fail without any error message:

CleanShot.2024-01-15.at.11.16.42.mp4

I tried those actions to run tests:

require('neotest').run.run(vim.fn.getcwd())

and

require('neotest').run.run({suite = true})

My configuration:

return {
  'nvim-neotest/neotest',
  dependencies = {
    'vim-test/vim-test',
    'nvim-lua/plenary.nvim',
    'nvim-treesitter/nvim-treesitter',
    'antoinemadec/FixCursorHold.nvim',
    'sidlatau/neotest-dart',
  },
  opts = function()
    return {
      -- your neotest config here
      adapters = {
        require 'neotest-dart' {
          command = 'fvm flutter', -- Command being used to run tests. Defaults to `flutter`
          -- Change it to `fvm flutter` if using FVM
          -- change it to `dart` for Dart only tests
          use_lsp = true, -- When set Flutter outline information is used when constructing test name.
          -- Useful when using custom test names with @isTest annotation
          custom_test_method_names = {},
        },
      },
    }
  end,
  config = function(_, opts)
    require('neotest').setup(opts)

    vim.keymap.set('n', '<leader>tr', function()
      require('neotest').run.run()
    end, { desc = 'Run closest test' })

    vim.keymap.set('n', '<leader>td', function()
      require('neotest').run.run { strategy = 'dap' }
    end, { desc = 'Debug closest test' })

    vim.keymap.set('n', '<leader>ta', function()
      require('neotest').run.run({suite = true})
    end, { desc = 'Run all tests' })

    vim.keymap.set('n', '<leader>to', function()
      require('neotest').output.open { enter = true }
    end, { desc = 'Open test output' })

    vim.keymap.set('n', '<leader>top', function()
      require('neotest').output_panel.toggle()
    end, { desc = 'Toggle test output panel' })

    vim.keymap.set('n', '<leader>tw', function()
      require('neotest').watch.toggle()
    end, { desc = 'Toggle test watcher' })

    vim.keymap.set('n', '<leader>ts', function()
      require('neotest').summary.toggle()
    end, { desc = 'Toggle test summary' })
  end,
}

No test found without Treesitter

I want neotest to use lsp to get test name, but still get No test found error.
Screenshot 2024-02-28 at 11 49 18 AM

Here is my config, I'm using lazy.nvim as plugin manager. What should I do to make it work with lsp?
Screenshot 2024-02-28 at 11 49 50 AM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.