voldikss / vim-floaterm

:computer: Terminal manager for (neo)vim
MIT License
2.46k stars 79 forks source link

Cannot run javascript jest tests in a floaterm #391

Open Danthewaann opened 1 year ago

Danthewaann commented 1 year ago

Before reporting

Environment

If you are using vim(not neovim), fill in the following blanks

If you are using neovim, just run :checkhealth floaterm and post the content

below.

Configurations related to vim-floaterm in vimrc(i.e. g:floaterm_xxx):

Describe your question, feature request, or bug.

Hi,

I currently using vim-test to try and run some javascript jest tests through a floaterm. However when I attempt to run the nearest test to the cursor it fails to find the test. The command that is being ran by vim-test is the following:

FloatermNew --autoclose=0 node_modules/.bin/jest --no-coverage --runTestsByPath -t '^When we call is HubAPIError\(\) Should return false for a default axios error response$' -- __tests__/errorHelpers-test.js

When I manually run the above jest command in a regular terminal, it successfully finds the test and runs it.

Steps to reproduce

Using the minimal vimrc

set nocompatible
set hidden
set termguicolors
set runtimepath^=/path/to/vim-floaterm
filetype plugin indent on
syntax on

Steps to reproduce the behavior:

  1. Install npm and nodejs
  2. Create a new javascript project with npm init (accept all the defaults as they don't matter here)
  3. Install jest with npm install jest
  4. Run mkdir __tests__
  5. Run the following in your terminal to create a dummy test
cat << EOF > __tests__/errorHelpers-test.js 
describe("When we call isHubAPIError()", () => {
    it("Should return false for a default axios error response", () => {
        expect(true).toEqual(true);
    });
});
EOF
  1. Run vim . to start up vim in your javascript project
  2. Finally run the following vim command to see the error described above:
FloatermNew --autoclose=0 node_modules/.bin/jest --no-coverage --runTestsByPath -t '^When we call is HubAPIError\(\) Should return false for a default axios error response$' -- __tests__/errorHelpers-test.js

Actual behaviour

The jest test is skipped as it seems to not match the regex, even though the same jest command works in a regular terminal.

Expected behaviour

The jest test should be found and run in a floaterm as expected.

Screenshots(Optional, GIF is better)

This a screenshot of the error that I'm getting:

image