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

Better error messages #4011

Closed
4 tasks done
basickarl opened this issue Aug 24, 2023 · 2 comments · Fixed by #6686
Closed
4 tasks done

Better error messages #4011

basickarl opened this issue Aug 24, 2023 · 2 comments · Fixed by #6686
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@basickarl
Copy link

Clear and concise description of the problem

Currently when an issue arises inside a test the error message receives give no information as to which test failed. So manually having to comment every test one by one until the issue is found is time consuming.

One line of code caused the following:

 FAIL  __tests__/table/tables.test.tsx [ __tests__/table/tables.test.tsx ]
Error: Missing "./src/table" specifier in "@neo4j-ndl/react" package
 ❯ e ../../node_modules/vitest/node_modules/vite/dist/node/chunks/dep-df561101.js:21420:25
 ❯ n ../../node_modules/vitest/node_modules/vite/dist/node/chunks/dep-df561101.js:21420:627
 ❯ o ../../node_modules/vitest/node_modules/vite/dist/node/chunks/dep-df561101.js:21420:1297
 ❯ resolveExportsOrImports ../../node_modules/vitest/node_modules/vite/dist/node/chunks/dep-df561101.js:28712:20
 ❯ resolveDeepImport ../../node_modules/vitest/node_modules/vite/dist/node/chunks/dep-df561101.js:28731:31
 ❯ tryNodeResolve ../../node_modules/vitest/node_modules/vite/dist/node/chunks/dep-df561101.js:28419:20
 ❯ Context.resolveId ../../node_modules/vitest/node_modules/vite/dist/node/chunks/dep-df561101.js:28180:28
 ❯ Object.resolveId ../../node_modules/vitest/node_modules/vite/dist/node/chunks/dep-df561101.js:44207:64
 ❯ TransformContext.resolve ../../node_modules/vitest/node_modules/vite/dist/node/chunks/dep-df561101.js:43923:23

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

 Test Files  1 failed (1)
      Tests  no tests
   Start at  20:59:09
   Duration  4.84s (transform 1.43s, setup 141ms, collect 0ms, tests 0ms, environment 387ms, prepare 130ms)

Very frustrating. At least give the line where the issue arose.

Suggested solution

Tell us which test has the code which is faulty. Preferably the line in the file.

Alternative

No response

Additional context

No response

Validations

@sheremet-va
Copy link
Member

Technically we can always mark errors with current suite to show it. Especially if error happened outside of test context in the main thread.

But what might be even better is to rethrow the error with stack trace in the test thread

@sheremet-va sheremet-va added the enhancement New feature or request label Aug 27, 2023
@sheremet-va sheremet-va added the p2-nice-to-have Not breaking anything but nice to have (priority) label Feb 16, 2024
@sheremet-va sheremet-va moved this to P2 - 4 in Team Board Oct 2, 2024
@sheremet-va sheremet-va removed the enhancement New feature or request label Oct 2, 2024
@sheremet-va sheremet-va moved this from P2 - 4 to Has plan in Team Board Oct 10, 2024
@hi-ogawa
Copy link
Contributor

hi-ogawa commented Oct 11, 2024

I made a simple example to compare Vitest and Vite https://stackblitz.com/edit/vitest-dev-vitest-z8mdl3?file=src%2Fentry.js

There might be a few factor to this issue. For example, Vitest's transform mode (web vs. ssr) affects import analysis and the throw error might depend on that.

This is an error when Vitest failed by import 'not-found':

$ vitest /repro-web

 FAIL  test/repro-web.test.js [ test/repro-web.test.js ]
Error: Failed to resolve import "not-found" from "src/entry.js". Does the file exist?
 ❯ TransformPluginContext._formatError node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:49242:41
 ❯ TransformPluginContext.error node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:49237:16
...

$ vitest /repro-ssr

 FAIL  test/repro-ssr.test.js [ test/repro-ssr.test.js ]
Error: Failed to load url not-found (resolved id: not-found) in /home/projects/vitest-dev-vitest-z8mdl3/src/entry.js. Does the file exist?
 ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51907:17

Vite shows a code frame for the same error on terminal and error overlay:

$ vite dev

1:24:34 PM [vite] Internal server error: Failed to resolve import "not-found" from "src/entry.js". Does the file exist?
  Plugin: vite:import-analysis
  File: /home/projects/vitest-dev-vitest-z8mdl3/src/entry.js:2:9
  1  |  // vite shows frame
  2  |  import 'not-found';
     |          ^
  3  |  
  4  |  //
      at TransformPluginContext._formatError (file:///home/projects/vitest-dev-vitest-z8mdl3/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:49242:41)
      at TransformPluginContext.error (file:///home/projects/vitest-dev-vitest-z8mdl3/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:49237:16)
...

Another factor is that, for some resolution error, even Vite is not showing a code frame, so this probably requires a fix on Vite.

A following is the error on Vite with the code import 'vite/not-found', which is the probably the same case as OP:

$ vite dev

1:25:43 PM [vite] Internal server error: Missing "./not-found" specifier in "vite" package
  Plugin: vite:import-analysis
  File: /home/projects/vitest-dev-vitest-z8mdl3/src/entry.js
      at e (file:///home/projects/vitest-dev-vitest-z8mdl3/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:46028:25)
      at n (file:///home/projects/vitest-dev-vitest-z8mdl3/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:46028:627)
      at o (file:///home/projects/vitest-dev-vitest-z8mdl3/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:46028:1297)
      at resolveExportsOrImports (file:///home/projects/vitest-dev-vitest-z8mdl3/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:46649:18)
      at resolveDeepImport (file:///home/projects/vitest-dev-vitest-z8mdl3/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:46672:25)

Nonetheless, I'll try to make it work for the case for the first case on web transform mode.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants