Coder Social home page Coder Social logo

nvim-test's Issues

feature request: `go_back_immediately` to focus back directly after test start

Thanks, plugin works nice on my setup (using it for Ruby/rspec).

I have a feature request: I assumed the option termOpts < go_back would let me focus back my previous window immediately. Unfortunately the focus changes only after the test run is finished.
An option go_back_immediately (overriding go_back) would be great.

Currently my workaround is this
map <Leader>T :TestFile<CR><c-w><c-p> (execute TestFile and WindowPrevious).

[Feature Request] Allow passing environment variables to the runner

Some test runners can take configuration via environment variables as well. For example, vusted can take VUSTED_NVIM and VUSTED_ARGS.

We can pass those variables in the cmd field like so:

{ cmd = "VUSTED_ARGS='--headless --clean' vusted" }

But I think it would be better to provide native support like so:

{
  env = {
    VUSTED_ARGS = '--headless --clean',
  },
  cmd = 'vusted',
}

Internally, the env field will be converted to key=value string pairs and prefixed to the cmd field.

This is just a thought, it's ok if rejected :)

go - arguments completely ignored?

I've created some custom configuration to create a coverage file.

local nvimtest = require('nvim-test')
require('nvim-test.runners.go-test'):setup {
  args = { "test", "-v", "-cover", "-coverprofile", "coverage.out" },
}
nvimtest.setup()

And I can see that the configuration works:

image

But no coverage.out file gets created.

When I run it myself, it works fine.

go test -cover -coverprofile=coverage.out ./...

If I change the args to be nonsensical...

image

And run the test, well... it still works!

image

It looks like the args are completely ignored.

I have no idea how to view the command that was actually executed.

Dynamic working directory based off of current file

I've configured Rspec like this (which should probably be the default):

require('nvim-test.runners.rspec'):setup({
  command = "bundle",
  args = { "exec", "rspec" },
})

This works perfectly when I open neovim in the directory containing the Gemfile. However, this doesn't work when I'm working on a project with multiple roots:

project/
  a/
    Gemfile
    spec/a_spec.rb
  b/
    Gemfile
    spec/b_spec.rb

If I'm editing a_spec.rb, I'd want to execute bundle exec spec/a_spec.rb with { cwd = "a" }.

I propose the introduction of runner:find_working_directory(filename) to dynamically infer the working directory. In the case of RSpec, that implementation might look something like this (adapted from here):

function rspec:find_working_directory(filename)
  local gemfile = vim.fn.findfile("Gemfile", vim.fn.fnamemodify(filename, ":p") .. ";")
  return vim.fn.fnamemodify(gemfile, ":p:h:t")
end

Support for Dart/Flutter

Firstly, thank you for doing a great plugin for testing based on 100% Lua.
It would be nice if you can add more languages like vim-test does, especially for Dart/Flutter.

Thanks again!

Dynamic arguments at runtime

Hi,

the one thing I am really missing at the moment, is to pass arguments to the test command on the fly.
Using pytest for example, every now and then it is really helpful to get more verbose output via -vvv or to drop into the debugger if a test fails with --pdb
Ideally one could append these extra flags to the test command, like: TestNearest -vvv --pdb

Is this already doable and I missed how to do it? Otherwise this would be a really helpful feature.

Thanks,
Andreas

vim.treesitter.query.set_query() is deprecated warning

The latest version of neovim is throwing the following deprecation warning.

Warn  10:55:20 notify.warn vim.treesitter.query.set_query() is deprecated, use vim.treesitter.query.set() instead. :help deprecated

This feature will be removed in Nvim version 0.10

support for jest ECMA scripts

hello ๐Ÿ‘‹

according to the jest docs the command to test ECMA scripts is the following

node --experimental-vm-modules node_modules/jest/bin/jest.js

is there a way to model this with the plugin?? I can't implement the jest runner

Possibility to pass custom cmd and working directly to runners

Hi,

First of all, awesome lib! :)

It would be nice to have the possibility to define the command at runtime that should be used to run the tests. This is useful for local binaries. For example, when using poetry, to run pytest I either have to run poetry run pytest or call it directly from the venv's bin (which is not activated). I solved that locally by doing:

local pytest = require("nvim-test.runners.pytest")
function pytest:build_cmd(filename, opts)
  local cmd
  if vim.env.VIRTUAL_ENV then
    cmd = vim.env.VIRTUAL_ENV .. "bin/pytest"
  else
    cmd = require("utils").find_cmd("pytest", ".venv/bin", filename)
  end
  return ("%s%s"):format(cmd, pytest:build_args(filename, opts or {}))
end

But it would be nice to have a proper config for it. (obs. that find_cmd is this function: https://github.com/bellini666/dotfiles/blob/master/vim/lua/utils.lua#L186)

Also, I work with monorepos and because of that the config for pytest is inside a subdirectory of where my cwd is. To properly run pytest, I need to "cd" to the subdirectory before running it.

It would be nice to have an option to pass a function similar to the above, that returns a directory that will be used to run the command from.

Both could also be the same function, that could return a table with both options (the ones not set would fallback to the default ones)

feature request - add TestAll command

I don't really mind if I'm in a test file or not, I often want to run all the tests.

At the moment, in a Go file like api.go, when I use the TestSuite command, it complains "not a test file".

image

I'd love to be able to run go test ./... from any file.

TestFile does not work for csharp and go

As we already discussed here #12 (comment) "TestFile" does not work for csharp and go tests.

Did you have already some ideas how we could refactor to support that feature for those languages?

If not and you don't mind I could create a PR with a suggestion.

What do you think?

Reuse existing terminal window for additional tests

Hey,

thanks for this handy plugin!

I noticed if I run a test (e.g. via TestNearest), change the test and run it again the new test session starts in a new, additional split window/terminal.

I think it would be cool if the existing terminal could be reused. Is this already possible? If not, I think it would be a nice addition.

Thanks,
Andreas

Error when setting up rspec runner command to be "bundle exec rspec"

Hello,

I'm having a bit of a problem when trying to use rspec runner.

I've noticed that your default setup is to just execute rspec.

Although this causes some problems when the project gem versions are not the same, for instance:

Gem::LoadError:
 You have already activated rspec-support 3.12.0, but your Gemfile requires rspec-support 3.11.1.
 Prepending `bundle exec` to your command may solve this

So I decided to look at replacing the command configuration to command = { "bundle exec rspec"}
But this caused another error when attempting to use :TestFile

E5108: Error executing lua Vim:E475: Invalid value for argument cmd: 'bundle exec rspec' is not executable
stack traceback:
        [C]: in function 'exec'
        .../packer/start/nvim-test/lua/nvim-test/terms/terminal.lua:54: in function 'run'
        [string ":lua"]:1: in main chunk

My setup

local status_ok, nvim_test = pcall(require, "nvim-test")

if not status_ok then
  return
end

nvim_test.setup({
  run = true,                 -- run tests (using for debug)
  commands_create = true,     -- create commands (TestFile, TestLast, ...)
  filename_modifier = ":.",   -- modify filenames before tests run(:h filename-modifiers)
  silent = false,             -- less notifications
  term = "terminal",          -- a terminal to run ("terminal"|"toggleterm")
  termOpts = {
    direction = "vertical",   -- terminal's direction ("horizontal"|"vertical"|"float")
    width = 96,               -- terminal's width (for vertical|float)
    height = 24,              -- terminal's height (for horizontal|float)
    go_back = false,          -- return focus to original window after executing
    stopinsert = "auto",      -- exit from insert mode (true|false|"auto")
    keep_one = true,          -- keep only one terminal for testing
  },
  runners = {               -- setup tests runners
    ruby = "nvim-test.runners.rspec",
  }
})


local rspec_runner = require("nvim-test.runners.rspec")

rspec_runner:setup({
  command = { "bundle exec rspec" }
})

Would it be possible to have bundle exec rspec whenever there's a Gemfile present?

How to stop test execution?

With the default setup, how can i stop running tests (i.e. if my tests a really long-running)?
Is closing the buffer enough? (not obvious).
The buffer does not seem to accept signals.
Calling :terminal during test run shows and empty terminal.

Support for more languages

Thank you for a great project!

I've been eager to replace vim-test with a Lua-based alternative, and this one seems to do more or less exactly what I need. However, I am missing support for RSpec and Hspec among others.

What would it take for me (or somebody else) to add support for more languages? Where does one start?

Passing arguments to tests

Hey there,
I'm using this plugin and its working great for me so far. There is something I'd like to customize but I haven't found a way to do it yet.

TestSuite runs a full set of tests. However - I want a way to just run a subset of tests. EG:
cargo test --lib --bins

Without running ALL the tests. What is the recommended way to achieve this?

Thanks!

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.