Skip to content

Log LOC for js syntax errors #6882

@j4k0xb

Description

@j4k0xb

Clear and concise description of the problem

When a js file has a syntax error, the logs only indicate that it failed to parse but not where.

 FAIL  test/suite.test.js [ test/suite.test.js ]
Error: Expression expected
 ❯ getRollupError node_modules/rollup/dist/es/shared/parseAst.js:558:41
 ❯ convertProgram node_modules/rollup/dist/es/shared/parseAst.js:1246:26
 ❯ Module.parseAstAsync node_modules/rollup/dist/es/shared/parseAst.js:2232:106
 ❯ ssrTransformScript node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:52430:11

Suggested solution

Show the same overview as for TS files, or at least the line/column number

FAIL  test/basic.test.ts [ test/basic.test.ts ]
Error: Transform failed with 1 error:
/home/projects/vitest-dev-vitest-bdbgdx/test/basic.test.ts:29:1: ERROR: Unexpected end of file
  Plugin: vite:esbuild
  File: /home/projects/vitest-dev-vitest-bdbgdx/test/basic.test.ts:29:1
  
  Unexpected end of file
  27 |  });
  28 |  
  29 |  -
     |   ^
  
 ❯ failureErrorWithLog node_modules/esbuild/lib/main.js:1462:15
 ❯ eval node_modules/esbuild/lib/main.js:745:50
 ❯ responseCallbacks.<computed> node_modules/esbuild/lib/main.js:612:9
 ❯ handleIncomingPacket node_modules/esbuild/lib/main.js:667:12
 ❯ Socket.readFromStdout node_modules/esbuild/lib/main.js:590:7

Alternative

No response

Additional context

Use-case: simple editors like nano without syntax validation, automatically-generated test files

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions