vitest-dev / vscode

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

JSON.parse error different in extention and cli runs #350

Closed sf0rman closed 4 months ago

sf0rman commented 4 months ago

Describe the bug

When running test that expects a JSON.parse to fail, the error message shown in CLI vitest run and runs started from vitest vscode extension differ.

In order to satisfy one, the other will faile.

Reproduction

Running this test will pass using vitest run in the cli and will fail if run from the extension.

describe("JSON parse errors", () => {
  it("JSON parse", () => {
    expect(() => JSON.parse("JUST SOME TEXT")).toThrowError(
      new SyntaxError("Unexpected token J in JSON at position 0")
    );
  });
});

image image


Extension v0.6.3

package.json

{
  "name": "vitestprob",
  "version": "1.0.0",
  "type": "module",
  "devDependencies": {
    "@types/node": "20.12.7",
    "typescript": "5.4.5",
    "vitest": "1.5.0"
  }
}

vitest.config.ts

import { defineConfig, UserConfigExport } from "vitest/config";

export default defineConfig({
  test: {
    include: ["**/*.test.ts"],

    environment: "node",
    cache: false,
  },
  logLevel: "info",
  esbuild: {
    sourcemap: "both",
  },
} satisfies UserConfigExport);

Output

[INFO 10:26:49] Running 1 file(s) with name pattern: ^\s?JSON parse errors JSON parse$

Version

0.6.3

Validations

sheremet-va commented 4 months ago

What Node version do you use in a CLI?

sf0rman commented 4 months ago

I was on node 18, but looks like you've completed this. Thanks! Updated vitest extention and it's all working.