vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Vitest reports 'No test suite found in file' when run from within VS2019 build/publish

Open jez9999 opened this issue 1 year ago • 0 comments

Describe the bug

When I run Vitest as part of my VS2019 project build, Vitest apparently can't find my test suites. It works fine if I run from the commandline:

npm run test:unit:nowatch

> [email protected] test:unit:nowatch
> vitest run --no-color --environment jsdom


 RUN  v0.23.2 C:/Development/MyApp/MyApp.Web/ClientApp

 ✓ src/lib/__tests__/libHex.spec.js (4)
 ✓ src/components/__tests__/Counter.spec.js (1)

Test Files  2 passed (2)
     Tests  5 passed (5)
  Start at  19:09:04
  Duration  1.64s (transform 533ms, setup 1ms, collect 200ms, tests 13ms)

But as part of a VS2019 build/publish, I get the error in the output window:

Error : No test suite found in file

Reproduction

Setup a VS2019 project that contains an npm run script as part of the build/publish process, ie. a .csproj file like:

  <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
    <!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run test:unit:nowatch" />

... with a package.json containing:

"scripts": {
  "test:unit:nowatch": "vitest run --no-color --environment jsdom"
}

And try to publish.

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
    Memory: 3.66 GB / 15.64 GB
  Binaries:
    Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.423.0), Chromium (105.0.1343.33)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    @vitejs/plugin-vue: ^3.0.1 => 3.1.0
    vite: ^3.0.4 => 3.1.0
    vitest: ^0.23.0 => 0.23.2

Used Package Manager

npm

Validations

jez9999 avatar Sep 12 '22 18:09 jez9999