Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Test result not found" for all tests #47

Closed
itpropro opened this issue Jun 9, 2022 · 64 comments
Closed

"Test result not found" for all tests #47

itpropro opened this issue Jun 9, 2022 · 64 comments
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@itpropro
Copy link

itpropro commented Jun 9, 2022

I have the same problem as in this already closed issue #8 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

  • Windows 11 21H2
  • VSCode 1.67.2
  • Extension v0.2.12
  • TypeScript 4.7.3

vite.config.js

import { defineConfig } from 'vite'

export default defineConfig({})

There is also an issue in the vitest repo:
vitest-dev/vitest#1407

@itpropro itpropro added the p3-minor-bug An edge case that only affects very specific usage (priority) label Jun 9, 2022
@zxch3n
Copy link
Member

zxch3n commented Jun 9, 2022

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
Copy link
Author

itpropro commented Jun 9, 2022

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
Copy link
Author

itpropro commented Jun 9, 2022

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
Copy link
Author

itpropro commented Jun 9, 2022

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
Copy link
Member

zxch3n commented Jun 10, 2022

Thanks. I'll look into it

@juananmuxed
Copy link

Hi have the same issue,

Im waiting for news, thanks!

@TimFeldmann-Work
Copy link

TimFeldmann-Work commented Jun 14, 2022

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
Copy link
Contributor

xon52 commented Jun 18, 2022

@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
Copy link
Member

zxch3n commented Jun 18, 2022

@xon52 dynamic test name is not supported yet

@zxch3n
Copy link
Member

zxch3n commented Jun 18, 2022

@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
Copy link
Author

@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
Copy link
Member

zxch3n commented Jun 19, 2022

@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
Copy link
Author

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

@juananmuxed
Copy link

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
Copy link
Member

zxch3n commented Jun 20, 2022

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

@btmnk
Copy link

btmnk commented Jun 20, 2022

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
Copy link

@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
Copy link
Member

zxch3n commented Jun 20, 2022

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

@zxch3n
Copy link
Member

zxch3n commented Jun 20, 2022

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

@juananmuxed
Copy link

Maybe works if I add "global": true ?

imagen

@kingyue737
Copy link

In pre-release version

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

image

@zxch3n
Copy link
Member

zxch3n commented Jun 22, 2022

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

@zxch3n
Copy link
Member

zxch3n commented Jun 22, 2022

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

@kingyue737
Copy link

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
Copy link

GDX64 commented Jun 25, 2022

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
Copy link

@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
Copy link

leonbloy commented Jun 28, 2022

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
Copy link

firemuzzy commented Jun 30, 2022

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

@huw
Copy link

huw commented Dec 4, 2022

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
Copy link

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

image

image

@ajthinking
Copy link

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
Copy link

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

@elizatlawy
Copy link

Same problem here using Yarn

@colecrouter
Copy link

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
Copy link

abarke commented May 8, 2023

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

image

image

@abarke
Copy link

abarke commented May 8, 2023

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
Copy link

edobrb commented May 10, 2023

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
Copy link

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
Copy link

simmzl commented Jun 29, 2023

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.

@RishikeshVedpathak
Copy link

I was getting this issue on Windows. I solved it by adding "vitest.commandLine": "npx vitest" to my VSCode's workspace settings.

image

@drewbitt
Copy link

drewbitt commented Jul 29, 2023

I was able to solve this by updating vscode-js-debug to Nightly as the latest vscode-js-debug did not support node installed via fnm and there was a node versioning issue of some kind.

Open the extensions view (ctrl+shift+x) and search for @builtin @id:ms-vscode.js-debug
Right click on the JavaScript Debugger extension and Disable it.
Search for @id:ms-vscode.js-debug-nightly in the extensions view.
Install that extension.

And for debugging, make sure you setup the launch.json as described by Vitest https://vitest.dev/guide/debugging.html

@selfrefactor
Copy link

This issue should be reopened as it is far from resolved. This makes using vitest not as appealing as it looks initially. Downgrading as solution looks bad.

@ngxCoder
Copy link

ngxCoder commented Aug 3, 2023

I solved the issue Reloading VsCode
Ctrl + P > "Reload Window"

image

@selfrefactor
Copy link

I keep receiving the error but test do start, so I do receive both error output and correct output. That Vitest had out-of-box working debug for VSCode was the sale point when I considered switching from Jest to Vitest.

@jzillmann
Copy link

jzillmann commented Sep 28, 2023

Fixed it in my mono-repo by creating vitest.workspace.ts in the root:

export default ['backend', 'frontend'];

See https://vitest.dev/guide/workspace.html

Update: Additionally I run into #183 which seems to produce the "Test result not found" issue sporadically.

@andrerpena
Copy link

After struggling for too long, I realised that, if there is a TypeScript compilation error, it will say "Test result not found"

Make sure to:

npx vitest [path-to-your-test]

... because it will tell you the real error

@Polcsi
Copy link

Polcsi commented Oct 17, 2023

I was struggling with the same issue and finally I found a solution for my problem. I want to share my solution in case helpful for someone.

I want to create a test file like this:

describe("Test", () => {
    it("Render Banners", () => {
        render(<Component />);

        expect(true).toBe(true);
    });
});

This code reproduce this error for me:

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?

After hours of trying I noticed something in the terminal:
image
It says there is a problem with some packages. So I tried to mock these packages in case solve the issue.

vi.mock("@uiw/react-color", () => ({
    default: vi.fn(),
}));

describe("Test", () => {
    it("Render Banners", () => {
        render(<Component />);

        expect(true).toBe(true);
    });
});

It worked. I just mocked that package and the errors disappeared.

@mathieucivel
Copy link

I also head-scratched for a while until I tried to remove a yarn linked dependency. I had this error in the vscode output:

TypeError: vue.createApp is not a function

 ❯ Object.<anonymous> ../../path-of-a-linked-dependency

So I ran yarn unlink [my-dependency] and yarn install --force, and the issue was solved.

It may have been a problem on top of the others, as I kept all the previous workarounds in this thread.

@gregpalaci
Copy link

gregpalaci commented Dec 1, 2023

For me it was because vitest in vscode could reslove my custom set in my tsconfig.json, the CLI yarn test worked fine but vscode sidebar did not.

Oddly vitest doesnt offer any kind of hint that this was the issue.

...
resolve: {
    alias: {
      '@utils': resolve(__dirname, './src/utils'),
      '@test': resolve(__dirname, './test'),
      '@src': resolve(__dirname, './src'),
    },
  },
...

To match my tconfig

...
"paths": {
      "@test/*": ["../test/*"],
      "@utils/*": ["./utils/*"],
      "@src/*": ["./*"]
    }
...

@Metehan-Altuntekin
Copy link

@gregpalaci was it because you were using them like import utils from "@utils"?

@Metehan-Altuntekin
Copy link

Metehan-Altuntekin commented Jan 11, 2024

In my case, I am using a monorepo with pnpm. It was firstly not even seeing the tests. Then I have set the vitest.workspace.ts and installed vitest to the root of the monorepo. It started working in the workspace but it also started throwing this error with svelte.

Edit: I have found that I can just open VS Code at the workspace directory and it just works! The initial configurations from Svelte Kit setup is enough for my case. This might be annoying for some that is working in multiple workspaces at the same time but enough for my use case.

This the link to the workspace in the monorepo in case anyone wants to take a look:
https://github.com/cozemble/breezbook/tree/main/apps/booking

@gregpalaci
Copy link

The other issue I found was you can't use variables as descriptions as mentioned #47 (comment)
You can start with a string and add a variable in a template literal but not vice versa
it(`should ${something}`)
is ok but
t(`${something} should`)
is not ok

@ajthinking
Copy link

Im in a monorepo and found a possible solution: Adding an additional vitest.config.ts in root.

Here is my structure:

├── packages
│   ├── core
│     ├── vitest.config.ts // These are not enough
│   ├── ui
│   ├── etc
├── vitest.config.ts // <----- Add this
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    globals: true,
  },
})

And we are green ✅

@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests