vscode icon indicating copy to clipboard operation
vscode copied to clipboard

The command line is too long

Open peterbud opened this issue 3 years ago • 2 comments

Describe the bug Vitest VS Code extension fails if you have many test files in folders with the following error message: [INFO 9:37:34 AM] The command line is too long.

To Reproduce I have many tests files in the project (70+), in subfolders. When in Test Explorer I click on "Run Tests (Default)", all the tests fail.

In the Vitest output window it's clear that the command line is a huge concatenated cmd:

Error when running
    c:\Users\[redacted...]\[project name]\node_modules\.bin\vitest.cmd
    C:/Users/[redacted...]/[project name]/test/basic.test.ts
    C:/Users/[redacted...]/[project name]/test/basic.test.ts
    
    etc. all the 70+ files

Clicking on individual test nodes, right click selecting "Run Test" works fine

Also running vitest from the command line works without any issue for all the test files

Expected behavior Tests should be executed even if there are high number of tests in the project in multiple folders

Environment

  • OS: Windows 11
  • VSCode version:
  • Vitest version: 0.22.1
  • Vitest plugin version: 0.2.28

Additional context This extension is great BTW!

peterbud avatar Aug 29 '22 07:08 peterbud

Windows limitation - https://stackoverflow.com/questions/29354602/powershell-error-the-command-line-is-too-long

Pustinyak avatar Aug 30 '22 05:08 Pustinyak

I understand the limitation - the question is would it be possible to check the length of the arguments before executing Vitest, and split the arguments if they are longer than this limit, and excute with Vitest the individual "chunks" individually?

peterbud avatar Aug 31 '22 10:08 peterbud

Running into this issue, as well.

It basically means the "Run Tests" (i.e. "run all") button doesn't work on Windows if you have a lot of tests.

If this is difficult to fix then at least a working temporary fix for Windows would be nice, even if it doesn't perform as well. E.g. run each test separately, or something like that.

It also just occurred to me... is it necessary to provide the entire list? Wouldn't the "Run Tests" button be the same as just letting Vitest use the "include" configuration? Maybe I am missing something about how it works?

Sverri avatar Jan 04 '23 09:01 Sverri

This should be fixed in pre-release 0.5.0 and higher. Note that the extension now requires Vitest 1.4.0 or higher.

The extension doesn't use the command line anymore to run tests, we call Vitest API directly, so there is no limit on how many tests are passed down.

sheremet-va avatar Mar 15 '24 18:03 sheremet-va