vscode: Monorepo instructions are unclear, samples not working

Describe the bug Currently, there is (some) support for monorepos, but how to actually get extension working for monorepos is unclear.

The monorepo examples in /samples don’t work out of the box as well.

To Reproduce Steps to reproduce the behavior on the example project:

  1. Clone this repository
  2. Open samples/monorepo in vscode
  3. Install the extension
  4. Run pnpm install
  5. Run all tests from the extension

Expected behavior The tests should run successfully.

Screenshots If applicable, add screenshots to help explain your problem. Screenshot 2022-09-06 at 16 45 43

Environment

(Paste info.txt content generated by the example project)

{
  "System": {
    "OS": "macOS 12.3.1"
  },
  "Binaries": {
    "Node": {
      "version": "16.14.0",
      "path": "~/.nodenv/versions/16.14.0/bin/node"
    },
    "Yarn": {
      "version": "1.22.15",
      "path": "~/.nodenv/versions/16.14.0/bin/yarn"
    },
    "npm": {
      "version": "8.3.1",
      "path": "~/.nodenv/versions/16.14.0/bin/npm"
    }
  },
  "IDEs": {
    "VSCode": {
      "version": "1.70.2",
      "path": "/opt/homebrew/bin/code"
    }
  },
  "npmPackages": {
    "vite": {
      "installed": "2.9.15",
      "wanted": "^2.9.9"
    },
    "vitest": {
      "installed": "0.12.10",
      "wanted": "^0.12.6"
    }
  }
}

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 11
  • Comments: 17 (4 by maintainers)

Most upvoted comments

@sheremet-va Then lets hope the pre-release also fixes finally that issue with these workspaces, where I have to manually do things that could have been just inferred correctly by searching for the closest vite(st) config 😕

There is no need to “hope”, you can install it yourself and see if it fixes it for you.

I finally found a proper workaround for something that should definitely be integrated into the plugin itself.

Please, use the latest pre-release version.

And add this to your .vscode/settings.json

The latest version doesn’t support vitest.commandLine option.

I’ve also been struggling to run my tests which, together, with vite.config.ts are located in a subfolder of my repo / workspace. The only thing that seems to work (somewhat) is setting the following in the VSCode workspace settings:

    "vitest.commandLine": "npx vitest --run --config mysubfolder/vite.config.ts",
    "vitest.include": [
      "**/mysubfolder/**/*.test.ts"
    ],

or (more or less equivalently)

    "vitest.commandLine": "npm run test",
    "vitest.include": [
      "**/mysubfolder/**/*.test.ts"
    ],

where the test command is defined in the package.json as:

  "test": "cd mysubfolder && vitest --run --config vite.config.ts",

Anyway, in both cases vitest then still reports “Test result not found […]” for every single test, even though the verbose test logs do report the test results, e.g.:

Test result not found. 
Are there tests with the same name?
Can you run vitest successfully on this file? Does it need custom option to run?

Vitest output:

 RUN  v0.25.1 /home/user/myrepo/mysubfolder
      API started at http://localhost:37661

 ❯ src/components/MyComponent/__tests__/MyComponent.test.ts  (11 tests | 1 failed | 10 skipped) 145ms
   ❯ src/components/MyComponent/__tests__/MyComponent.test.ts > MyComponent > shows error page on failed request
     → Unable to find an element by: [data-testid="generic-error-overlay"]

…

(DOM)

…

(stack trace)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

 Test Files  1 failed (1)
      Tests  1 failed | 10 skipped (11)
   Start at  16:04:15
   Duration  3.75s (transform 2.25s, setup 122ms, collect 2.18s, tests 145ms)

What gives?