vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
741 stars 83 forks source link

"Test result not found" for all tests #47

Closed itpropro closed 2 years ago

itpropro commented 2 years ago

I have the same problem as in this already closed issue https://github.com/vitest-dev/vscode/issues/8,the tests are working fine on the terminal (separate or VSCode integrated) but the tests are all failing in the extension:

image

From testing around I found that without any configuration, the result is this

 RUN  v0.14.1 E:/repos/project

⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/code.test.ts [ test/code.test.ts ]
Error: No test suite found in file E:/repos/project/test/code.test.ts
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Test Files  1 failed (1)
     Tests  no tests
      Time  1.84s (in thread 0ms, Infinity%)

And with "vitest.commandLine": "yarn test", it actually runs the test, but still displays everything as failed (probably because of the bottom part):

 RUN  v0.14.1 E:/repos/project

⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/code.test.ts [ test/code.test.ts ]
TypeError: params.map is not a function
...

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

Test Files  1 failed (1)
     Tests  no tests
      Time  1.70s (in thread 0ms, Infinity%)

JSON report written to C:/Users/xxx/AppData/Local/Temp/vitest-report-2v2t12.json
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given no parameters should be defined@2Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given no parameters should instantiate@3Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given parameters should be defined@5Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given parameters should work with parameters@6Cannot find test file:///e%3A/repos/project/test/code.test.ts/function02 should be defined@9Cannot find test file:///e%3A/repos/project/test/code.test.ts/function03 should be defined@11

System

vite.config.js

import { defineConfig } from 'vite'

export default defineConfig({})

There is also an issue in the vitest repo: https://github.com/vitest-dev/vitest/issues/1407

zxch3n commented 2 years ago

Can you change the setting to "vitest.commandLine": "yarn test --"? Is this reproducible on this repo https://github.com/zxch3n/vitest-ext-basic-example?

itpropro commented 2 years ago

Can you change the setting to "vitest.commandLine": "yarn test --"? Is this reproducible on this repo https://github.com/zxch3n/vitest-ext-basic-example?

I changed the workspace config to

{
  "vitest.commandLine": "yarn test --",
  "vitest.enable": true
}

unfortunately, without any change in behavior.

With the referenced repository using yarn (there was no lock file, so I used yarn) I have the same problem: image

EDIT: Here is the debug output

 RUN  v0.12.10 E:/repos/vitest-ext-basic-example

⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  add.test.ts [ add.test.ts ]
Error: No test suite found in file E:/repos/vitest-ext-basic-example/add.test.ts
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Test Files  1 failed (1)
     Tests  no tests
      Time  1.79s (in thread 0ms, Infinity%)

JSON report written to C:/Users/xxx/AppData/Local/Temp/vitest-report-6yrj1.json
Cannot find test file:///e%3A/repos/vitest-ext-basic-example/add.test.ts/add 1 + 1@1
itpropro commented 2 years ago

Ok, I think I have figured something out. It is definitely connected to using Yarn. I just recloned the repo and with pnpm i, the tests all run through and work fine, with yarn they all fail. Can you reproduce the yarn error on your side @zxch3n ?

itpropro commented 2 years ago

Unfortunately, moving my main project from yarn to pnpm didn't fix the problem, I still get the same "Test not found' error, but now I get this one in addition from time to time:

FATAL ERROR: v8::FromJust Maybe value is Nothing.
 1: 00007FF7AA5E79CF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114207
 2: 00007FF7AA576096 DSA_meth_get_flags+65542
 3: 00007FF7AA576F4D node::OnFatalError+301
 4: 00007FF7AAE95BF5 v8::V8::FromJustIsNothing+53
 5: 00007FF7AA55F083 v8::base::CPU::has_sse+31507
 6: 00007FF7AA64A947 uv_timer_stop+1207
 7: 00007FF7AA646EDB uv_async_send+331
 8: 00007FF7AA64666C uv_loop_init+1292
 9: 00007FF7AA64680A uv_run+202
10: 00007FF7AA615675 node::SpinEventLoop+309
11: 00007FF7AA4AE6F0 v8::internal::interpreter::BytecodeLabel::bind+35712
12: 00007FF7AA4A9D48 v8::internal::interpreter::BytecodeLabel::bind+16856
13: 00007FF7AA636EDD uv_poll_stop+557
14: 00007FF7AB450120 v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+146416
15: 00007FFAFFD754E0 BaseThreadInitThunk+16
16: 00007FFB00CA485B RtlUserThreadStart+43
zxch3n commented 2 years ago

Thanks. I'll look into it

juananmuxed commented 2 years ago

Hi have the same issue,

Im waiting for news, thanks!

TimFeldmann-Work commented 2 years ago

I had the same issue and while I was trying to resolve it vitest 0.15.0 was released so I upgraded figuring that might resolve the issue and now I'm receiving the following error exclusively when running my vitest through the vitest VSCode extension:

TypeError: Cannot redefine property: Symbol(expect-global)
node_modules/vitest/dist/chunk-vite-node-externalize.db158bfb.mjs:9022
 ❯ ......../share/node_modules/vitest/dist/chunk-runtime-chain.ce7f4b92.mjs:1856:8
node_modules/vitest/dist/chunk-vite-node-externalize.db158bfb.mjs:10409
    1854| }
    1855| const globalExpect = createExpect();
    1856| Object.defineProperty(globalThis, GLOBAL_EXPECT, {
       |        ^
    1857|   value: globalExpect
    1858| });

Again this only happens when running the test through the VSCode extension after upgrading vitest to 0.15.0. Before upgrading to 0.15.0, I received the same error as what was originally posted.

I am using npm as a package manager, not yarn.

My test:

test("Math.sqrt", () => {
    expect(Math.sqrt(4)).toBe(2);
    expect(Math.sqrt(144)).toBe(12);
    expect(Math.sqrt(2)).toBe(Math.SQRT2);
});
xon52 commented 2 years ago

@zxch3n been a while but back in Vue and having this same issue again. I noticed some tests failing and some succeeding and the difference is as follows: image

It appears if I use any variables in the test name the VSCode Ext fails for that. Running npx vitest works fine for these.

zxch3n commented 2 years ago

@xon52 dynamic test name is not supported yet

zxch3n commented 2 years ago

@juananmuxed @TimFeldmann-Patriot @itpropro Can you check whether the pre-release version works now?

@xon52 now dynamic test name is partially supported in the pre-release version, but you need to run from its parent describe block/file.

itpropro commented 2 years ago

@zxch3n I just tested the newest version (0.2.14), but the tests are just stuck in the VSCode pane forever like this: image Running vitest manually on any console still works fine. Here is the debug output:

 DEV  v0.14.2 e:/repos/test

      API started at http://localhost:55497

filter:  E:/repos/test/func01.test.ts

include: **/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}

watch exclude:  **/node_modules/**, **/dist/**

No test files found, exiting with code 1

Just for testing, I updated to the most current vitest version, but the tests in VSCode are still stuck forever.

zxch3n commented 2 years ago

@itpropro I published a new version to pre-release (v0.2.15) that fixed the run forever issue. Can you check whether it works now?

itpropro commented 2 years ago

Hey @zxch3n, it works now 😀 Thank you so much for troubleshooting and fixing this, keep up the great work!

juananmuxed commented 2 years ago

Hey!

I'm checking and I have the same error

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:

 DEV  v0.15.1 D:/Proyectos/Webs/muxed-next/web
      API started at http://localhost:57093

I have the latest version v0.2.15

Nothing weird in the vitest.config.ts

  test: {
    environment: "jsdom",
    coverage: {
      reporter: ["text", "json", "html"],
    },
  },
zxch3n commented 2 years ago

@juananmuxed Can you switch to the pre-release version (v0.2.18) to test it again?

btmnk commented 2 years ago

I'm facing the same issue but I assume the reason is that we use a monorepo for our frontend and backend. I open vscode with the root directory so there is no package.json or any of the config files in the root directory but instead in one directory deeper (./frontend/package.json etc.)

When I open the project directly in the frontend directory it properly recognizes that there is vitest in place and the tests also run as expected (without the result not found error). I noticed however that it didn't use the excluded files defined in the vitest.config.ts file so it shows some other test files for playwright as well..

I think it would be nice to be able to configure this in the workspace (e.g. rootDir: "./frontend") or maybe let the extension check sub directories? (I'm not familiar with how extensions work or if this is even feasible)

juananmuxed commented 2 years ago

@juananmuxed Can you switch to the pre-release version (v0.2.18) to test it again?

Still not working

imagen

A simple mount render

import { describe, it, expect } from "vitest";
import { mount } from "@vue/test-utils";
import FooterVue from "../footer/Footer.vue";

describe("Footer", () => {
  describe("Props", () => {
    it("Default", async () => {
      const wrapper = mount(FooterVue);

      expect(wrapper).toMatchSnapshot();
    });
  });
});

Result:

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:

 DEV  v0.15.1 D:/Proyectos/Webs/muxed-next/web
      API started at http://localhost:59261

 ❯ src/components/__tests__/Footer.test.ts  (0 test)
zxch3n commented 2 years ago

@btmnk mono repo is not supported yet #6 #13 . As a workaround, you can use it with VSCode workspaces now, thanks to @evanandrewrose .

zxch3n commented 2 years ago

@juananmuxed Can you post the extension output? You can find it here, thanks

image
juananmuxed commented 2 years ago

Maybe works if I add "global": true ?

imagen

kingyue737 commented 2 years ago

In pre-release version

Although all my tests are run successfully, all the icons of file path become "error" after finished.

image

zxch3n commented 2 years ago

@kingyue737 Can you post the output from 'vitest' as well?

zxch3n commented 2 years ago

@juananmuxed Sorry, I don't know what caused your error. Can you reproduce it in https://github.com/zxch3n/vitest-ext-basic-example ?

kingyue737 commented 2 years ago

Explorer during running: image

Output:

[INFO 11:31:11] Tests run start
[INFO 11:31:11] [Workspace "online_monitor_front] Run tests from workspace
[INFO 11:31:11] [Execute Vitest] d:\Solutions\online_monitor_front\node_modules\.bin\vitest.cmd D:/Solutions/online_monitor_front/src/views/layout/__tests__/MonitorAlarms.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/NewPrediction.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/NewPDCRConfig.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/logViewer.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/expanded.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/actions.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/components/__tests__/LoadChangeTable.spec.ts D:/Solutions/online_monitor_front/src/views/layout/__tests__/AppMessage.spec.ts D:/Solutions/online_monitor_front/src/views/account/__tests__/LoginPage.spec.ts D:/Solutions/online_monitor_front/src/stores/__tests__/monitor.spec.ts D:/Solutions/online_monitor_front/src/stores/__tests__/message.spec.ts D:/Solutions/online_monitor_front/src/components/__tests__/viewLevel.spec.ts D:/Solutions/online_monitor_front/src/components/table/__tests__/DataListCard.spec.ts D:/Solutions/online_monitor_front/src/components/form/validateInputs/__tests__/TextField.spec.ts D:/Solutions/online_monitor_front/src/components/form/validateInputs/__tests__/BaseVldInput.spec.ts
[INFO 11:31:11] Start api process at port 54226
[INFO 11:31:11] [RUN] d:\Solutions\online_monitor_front\node_modules\.bin\vitest.cmd D:/Solutions/online_monitor_front/src/views/layout/__tests__/MonitorAlarms.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/NewPrediction.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/NewPDCRConfig.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/logViewer.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/expanded.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/actions.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/components/__tests__/LoadChangeTable.spec.ts D:/Solutions/online_monitor_front/src/views/layout/__tests__/AppMessage.spec.ts D:/Solutions/online_monitor_front/src/views/account/__tests__/LoginPage.spec.ts D:/Solutions/online_monitor_front/src/stores/__tests__/monitor.spec.ts D:/Solutions/online_monitor_front/src/stores/__tests__/message.spec.ts D:/Solutions/online_monitor_front/src/components/__tests__/viewLevel.spec.ts D:/Solutions/online_monitor_front/src/components/table/__tests__/DataListCard.spec.ts D:/Solutions/online_monitor_front/src/components/form/validateInputs/__tests__/TextField.spec.ts D:/Solutions/online_monitor_front/src/components/form/validateInputs/__tests__/BaseVldInput.spec.ts
[INFO 11:31:11] [RUN.cwd] D:/Solutions/online_monitor_front
[INFO 11:31:11] WS Close
[INFO 11:31:11] WS Close
[INFO 11:31:11] WS Close
[INFO 11:31:11] WS Close
[INFO 11:31:11] WS Close
[INFO 11:31:11] WS Close
[INFO 11:31:11] WS Close
[INFO 11:31:11] WS Close
[INFO 11:31:11] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:12] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:13] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:14] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:15] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:16] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:17] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:18] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:19] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Close
[INFO 11:31:20] WS Opened
[INFO 11:31:20] WS Opened
[INFO 11:31:21] 

 DEV  v0.15.1 D:/Solutions/online_monitor_front

      API started at http://localhost:54226

  > Inspect: http://localhost:54226/__inspect/

[INFO 11:31:30]  ✓ src/stores/__tests__/message.spec.ts  (2 tests) 11ms

[INFO 11:31:49]  ✓ src/components/__tests__/viewLevel.spec.ts  (8 tests) 739ms

[INFO 11:31:53]  ✓ src/components/table/__tests__/DataListCard.spec.ts  (2 tests) 131ms

[INFO 11:31:54]  ✓ src/stores/__tests__/monitor.spec.ts  (1 test) 10ms

[INFO 11:31:56]  ✓ src/views/account/__tests__/LoginPage.spec.ts  (1 test) 330ms

[INFO 11:31:57]  ✓ src/views/layout/__tests__/AppMessage.spec.ts  (1 test) 259ms

[INFO 11:31:58]  ✓ src/views/layout/__tests__/MonitorAlarms.spec.ts  (5 tests) 560ms

[INFO 11:31:59]  ✓ src/components/form/validateInputs/__tests__/BaseVldInput.spec.ts  (1 test) 89ms

[INFO 11:32:00]  ✓ src/components/form/validateInputs/__tests__/TextField.spec.ts  (10 tests) 308ms

[INFO 11:32:03]  ✓ src/views/online_monitor/prediction/__tests__/logViewer.spec.ts  (2 tests) 140ms

[INFO 11:32:16]  ✓ src/views/online_monitor/prediction/__tests__/expanded.spec.ts  (6 tests) 182ms

 ↓ src/views/online_monitor/prediction/__tests__/NewPDCRConfig.spec.ts  (5 tests | 5 skipped)

[INFO 11:32:16]  ✓ src/views/online_monitor/prediction/__tests__/actions.spec.ts  (12 tests | 6 skipped) 483ms

[INFO 11:32:21]  ✓ src/views/online_monitor/prediction/components/__tests__/LoadChangeTable.spec.ts  (5 tests) 1323ms

[INFO 11:32:22] Vitest api process finished
[Error 11:32:22] [Workspace "online_monitor_front] Run error
[INFO 11:32:22] [Workspace online_monitor_front] Error: TypeError: Cannot read properties of undefined (reading 'item')
[INFO 11:32:22] Tests run end
[INFO 11:32:22] API PROCESS EXIT
[INFO 11:32:22] Vitest api process finished
[INFO 11:32:22] WS Close
[INFO 11:32:22] WS Close
[Error 11:32:22] 
Failed to get any result
( Vitest should be configured to be able to run from project root )

Error when running
    d:\Solutions\online_monitor_front\node_modules\.bin\vitest.cmd D:/Solutions/online_monitor_front/src/views/layout/__tests__/MonitorAlarms.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/NewPrediction.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/NewPDCRConfig.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/logViewer.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/expanded.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/__tests__/actions.spec.ts D:/Solutions/online_monitor_front/src/views/online_monitor/prediction/components/__tests__/LoadChangeTable.spec.ts D:/Solutions/online_monitor_front/src/views/layout/__tests__/AppMessage.spec.ts D:/Solutions/online_monitor_front/src/views/account/__tests__/LoginPage.spec.ts D:/Solutions/online_monitor_front/src/stores/__tests__/monitor.spec.ts D:/Solutions/online_monitor_front/src/stores/__tests__/message.spec.ts D:/Solutions/online_monitor_front/src/components/__tests__/viewLevel.spec.ts D:/Solutions/online_monitor_front/src/components/table/__tests__/DataListCard.spec.ts D:/Solutions/online_monitor_front/src/components/form/validateInputs/__tests__/TextField.spec.ts D:/Solutions/online_monitor_front/src/components/form/validateInputs/__tests__/BaseVldInput.spec.ts

cwd: D:/Solutions/online_monitor_front
node: v16.15.1

env.PATH: undefined

[Error 11:32:22] 

 DEV  v0.15.1 D:/Solutions/online_monitor_front

      API started at http://localhost:54226

  > Inspect: http://localhost:54226/__inspect/

 ✓ src/stores/__tests__/message.spec.ts  (2 tests) 11ms

 ✓ src/components/__tests__/viewLevel.spec.ts  (8 tests) 739ms

 ✓ src/components/table/__tests__/DataListCard.spec.ts  (2 tests) 131ms

 ✓ src/stores/__tests__/monitor.spec.ts  (1 test) 10ms

 ✓ src/views/account/__tests__/LoginPage.spec.ts  (1 test) 330ms

 ✓ src/views/layout/__tests__/AppMessage.spec.ts  (1 test) 259ms

 ✓ src/views/layout/__tests__/MonitorAlarms.spec.ts  (5 tests) 560ms

 ✓ src/components/form/validateInputs/__tests__/BaseVldInput.spec.ts  (1 test) 89ms

 ✓ src/components/form/validateInputs/__tests__/TextField.spec.ts  (10 tests) 308ms

 ✓ src/views/online_monitor/prediction/__tests__/logViewer.spec.ts  (2 tests) 140ms

 ✓ src/views/online_monitor/prediction/__tests__/expanded.spec.ts  (6 tests) 182ms

 ↓ src/views/online_monitor/prediction/__tests__/NewPDCRConfig.spec.ts  (5 tests | 5 skipped)

 ✓ src/views/online_monitor/prediction/__tests__/actions.spec.ts  (12 tests | 6 skipped) 483ms

 ✓ src/views/online_monitor/prediction/components/__tests__/LoadChangeTable.spec.ts  (5 tests) 1323ms

[INFO 11:32:22]  ✓ src/views/online_monitor/prediction/__tests__/NewPrediction.spec.ts  (3 tests | 1 skipped) 157ms

Test Files  14 passed | 1 skipped (15)

     Tests  52 passed | 12 skipped (64)

      Time  61.38s (in thread 4.72s, 1299.88%)

 PASS  Waiting for file changes...

       press h to show help, press q to quit
GDX64 commented 2 years ago

I had this issue, what I did was updating both vue and vitest to the latest version and reloaded vscode window. Now I'm on:

"vitest": "^0.16.0", "vue": "^3.2.37", vitest extension: v0.2.19

juananmuxed commented 2 years ago

@juananmuxed Sorry, I don't know what caused your error. Can you reproduce it in https://github.com/zxch3n/vitest-ext-basic-example ?

Sorry for late response.

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:
"." no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.

Following all in the repo

leonbloy commented 2 years ago

I don't know why this issue was closed,

I've updated to the latests versions (vitest .16.0, vitest extension: 0.2.19 ) and to find the right combination of settings that make this work is a torture.

I would help a lot that the extension has some debug mode or something that spits info to help debugging.

Apart from the versions, there seems to be these factors into play:

  1. OS Windows/Mac/Linux

  2. vitest.commandLine setting

  3. npm/yarn

  4. node in nvm yes/no

  5. vs code terminal (cmd/powershell/bash)

In my case, I have Windows, node with nvm, npm. I start with powershell

I have in my my package json

scripts {
 "test": "vitest run",
 "testw": "vitest",
}

so that running in my terminal

 > npm run test test src/__test__/trivial.test.js
 > npm run testw test src/__test__/trivial.test.js

runs the test as expected (the latter in watch mode)

However the setting

"vitest.commandLine" : "npm run test" fails with "Test result not found... (etc)" in spite of the test terminal showing the expected output:

> vitest run "W:/wk/myp/src/__test__/trivial.test.js" "testOk" "52580"
Doing my global setup
 RUN  v0.16.0 W:/wk/myp
stdout | unknown test
trivialTests before all
stdout | src/__test__/trivial.test.js > testOk
test Ok  1656439421059
stdout | unknown test
trivialTests after all
 ✓ src/__test__/trivial.test.js  (2 tests | 1 skipped) 4ms
Test Files  1 passed (1)
     Tests  1 passed | 1 skipped (2)
      Time  4.25s (in thread 4ms, 106351.64%)
Done my global tear down
> Test run finished at 28/06/2022, 15:03:41 <

(it's strange the stdout | unknown test bit)

and the setting

"vitest.commandLine" : "npm run testw"

(in watch mode) simply hangs everythiong. The test ouptut terminal shows

     Test Files  1 passed (1)
     Tests  1 passed | 1 skipped (2)
     Time  4.18s (in thread 4ms, 104430.55%)
 PASS  Waiting for file changes...
       press h to show help, press q to quit

and the inprogres indicators (spinner, "Running tests messages") go forever. Restart required.

I try instead

"vitest.commandLine" : "npx vitest"

... and now it works. Don't know why

Ok. Now I want to switch to my preferred terminal: bash from git in windows.

I follow the recipe here https://stackoverflow.com/questions/42606837/how-do-i-use-bash-on-windows-from-the-visual-studio-code-integrated-terminal/72517865#72517865

And now I'm back to the "Test result not found" error

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:
Doing my global setup

 DEV  v0.16.0 W:/wk/myp
      API started at http://localhost:52928
stdout | unknown test
trivialTests before all
stdout | src/__test__/trivial.test.js > testOk
test Ok  1656439952028
 ✓ src/__test__/trivial.test.js  (2 tests | 1 skipped) 6ms
stdout | unknown test
trivialTests after all
firemuzzy commented 2 years ago

having the same "Test not found" issues with npm, running pre-release

hatton commented 2 years ago

v0.2.20, Yarn. Changing this setting fixed me, from @leonbloy above:

"vitest.commandLine" : "npx vitest"

AdmiralMurtho commented 2 years ago

With your example-Repository to test the Plugin i came to the same Result as the most here:

Test result not found

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:
Der Befehl "." ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

The tests are running correct and pass, after I added npm run test but the signs are keeping red and the error Test result not found stays

Jucesr commented 2 years ago

I am getting the same error. I will swich back to Jest until this is fixed

maxstue commented 2 years ago

I'm using yarn as well and only switching to globals: true setting fixed it for me.

wieringen commented 2 years ago

I have the same problem :/

jonsalvas commented 2 years ago

same issue here, ..

"vitest.commandLine" : "npx vitest"

only fixed it "partly". There are still tests failing with that error. The test result looks fine. If I run a single test it works perfectly fine. If I run all tests, some fail

LAWTED commented 2 years ago

same issue, and I found if u run the test again will be ok, hence every time I changed test file need to run test twice?

Pustinyak commented 2 years ago

Check my answers for examples how to fix this: https://github.com/vitest-dev/vscode/issues/55#issuecomment-1231161530 https://github.com/vitest-dev/vscode/issues/75#issuecomment-1231168755 https://github.com/vitest-dev/vscode/issues/77#issuecomment-1231151100

Quick explanation for all related issues is that v0.2.14 introduced a new way to fetch information for the running tests. We should be careful with our configurations and I guess we need to document these confusing errors...

The extension works fine for me and hopefully a monorepo solution would come in the future when the dev team decides how to support different setups and package managers.

zxch3n commented 2 years ago

Thanks, @Pustinyak! I added some extra error messages for the situations you listed.

leonadler commented 1 year ago

Two other reasons I found that can prevent this extension to run successfully:

  1. Changing the DNS resolver to use "localhost" instead of "127.0.0.1"
  2. Setting a fixed port (api: 12345 in vitest.config.ts)

We have some hostname-dependent configurations like CORS settings in our app which only work with localhost:port and not 127.0.0.1:port; when not using dns.setDefaultResultOrder the vitest-explorer extension works 👍🏻


So we set up vitest-explorer to provide us an enviroment variable and change the vite.config.ts to only change the DNS settings when not running through the vscode extension:

// .vscode/settings.json
  "vitest.nodeEnv": {
    "RUNNING_VIA_VITEST_EXPLORER": true
  }
// vite.config.ts
import dns from 'node:dns';

// Enforce "localhost" as hostname instead of "127.0.0.1" - https://vitejs.dev/config/server-options.html#server-host
// Skip when running through the the "vitest-explorer" VSCode extension.
if (!process.env.RUNNING_VIA_VITEST_EXPLORER) {
  dns.setDefaultResultOrder('verbatim');
}

The second thing we needed to change is to use the --api argument if it is supplied:

 // vitest.config.ts
 export default mergeConfig(viteConfig, defineConfig({
   // vitest-ui at http://localhost:12345/__vitest__/
-  api: 12345
+  api: Number(process.argv[process.argv.indexOf('--api') + 1]) || 12345,
 });

Versions: vscode: 1.71.2, node: 16.17.1, vite: 3.1.3, vitest: 0.23.4, vitest-explorer: 0.2.29

(Maybe not 100% the correct issue, but this is by far the issue that comes up first in Google)

polRk commented 1 year ago

Not working in monorepo

Test result not found. 
If you set `vitest.commandLine` please check: 
    Did you set `vitest.commandLine` to `run` mode? (This extension requires `watch` mode to get the results from Vitest api)
    Does it have the ability to append extra arguments? (For example it should be `yarn test --` rather than `yarn test`)
Are there tests with the same name?
Can you run vitest successfully on this file? Does it need custom option to run?

Vitest output:

 DEV  v0.23.4 /workspaces/123
      API started at http://127.0.0.1:43211

 ❯ apps/proxy/src/websites/website.test.ts  (0 test)
huw commented 1 year ago

There’s a common error when running with a nested multi-root workspace (i.e. root and root/package/a are both entrypoints in your VS Code workspace). The Vitest runner will try to run your test with a root CWD, and a root/package/a CWD simultaneously. In root/package/a, it’ll pick up your config properly & run the test correctly, but in root it’ll miss your config, and if your test depends on that it will fail.

The extension then picks up on a successful & a failing/misconfigured test result, and gets confused. You can see this if you go to the Vitest section in the Output tab.

The fix is simple (in your .code-workspace file):

"vitest.disabledWorkspaceFolders": ["root"]

Then restart VS Code. The extension doesn’t pick up on config changes until you do. @zxch3n I think this is the source of most of the errors of this kind, just judging by what people are reporting.

GreatAuk commented 1 year ago

if I use docblock to set environment, it happens every time.

image image image
ajthinking commented 1 year ago

I have this error even though I'm not in a mono repo. Restarting VS Code fix it sometimes. No problems in terminal. package.json has script "test": "vitest" and this is my vitest.config.js:

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    globals: true,
  },
})
airRnot1106 commented 1 year ago

This error occurs the first time the test is run; it does not occur the second or subsequent times.

elizatlawy commented 1 year ago

Same problem here using Yarn

colecrouter commented 1 year ago

I have never been able to get this to work. I set

"vitest.commandLine": "npm run test --"

an

"test": "npx vite"

and it gives this:

> website@0.0.1 test
> npx vitest /[redacted]/thing.test.ts -t should show the profile menu --api.port 56041 --api.host 127.0.0.1

 DEV  v0.31.0 [redacted]
      API started at http://127.0.0.1:56041

 ❯ thing.test.ts  (0 test)

if I take the exact same command

npx vitest /[redacted]/thing.test.ts -t should show the profile menu --api.port 56041 --api.host 127.0.0.1

and run it, it works fine. I can't imagine what would cause this? Wrong folder? It's an absolute path.

abarke commented 1 year ago

I have the same issue. Such a shame. Have no idea why. Super simple setup. CLI works. VS Code Extension fails:

image

image

abarke commented 1 year ago

OK I found the issue and it works for me now. Seems vitest does not like vite v4.x.x

Try forcing it to use v3.x.x

image

edobrb commented 1 year ago

I'm having the same issue as @abarke but downgrading vite to 3.2.6 seems to do nothing. Only VS Code Extension fails.

sunts-share commented 1 year ago

I'm having the same issue just in Windows. It works fine in WSL2.

I've tried to change Vitest: Command Line like below, all failed. npx vitest npm run test -- (use default empty settings)

In WSL2, just keep Vitest: Command Line empty.

My vite.config.ts is like below:

      test: {
        // enable jest-like global test APIs
        globals: true,

        include: ["tests/unit/**/*.{test,spec}.{ts,js}"],
        environment: "happy-dom", // or 'jsdom', 'node'

        // Reference: https://vitest.dev/guide/coverage.html
        coverage: {
            provider: "istanbul", // or 'v8'
            reporter: ["text", "html"], // , "clover", "json"
            reportsDirectory: "./tests/coverage",
        },

I've tried to change the extension code like below, and got a new dist/extension.js with compile, and the "No test files found" error was cleared. But, "Test result not found" is still shown...

        // runner.ts

    const workspacePathWithSlash = sanitizeFilePath(`${this.workspacePath}/`, true)
    const getRelativePath = (filePath: string) => {
      if (filePath.startsWith(workspacePathWithSlash))
        return filePath.substring(workspacePathWithSlash.length)

      return filePath
    }

    const args = [
      ...vitestCommand.args,
      ...(testFile ? testFile.map(f => getRelativePath(sanitizeFilePath(f, true))) : []),
    ] as string[]
    if (updateSnapshot)
      args.push('--update')
simmzl commented 1 year ago

I'm having the same issue,but I solved it!

My global node version is 14. In my project, I temporarily changed the version under the project to 16 by nvm. The extension don't work.

Then I changed the global node version to be consistent with my project version, and with "vitest.commandLine": "npx vitest",it worked fine.