vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.45k stars 1.84k forks source link

Log prefix breaks Jest extension for VS Code #8647

Open OliverJAsh opened 4 months ago

OliverJAsh commented 4 months ago

Verify canary release

Link to code that reproduces this issue

https://github.com/OliverJAsh/turbo-vscode-jest-2

What package manager are you using / does the bug impact?

Yarn v2/v3/v4 (node_modules linker only)

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

2.0.6-canary.0

Describe the Bug

When Turborepo is used in combination with the Jest extension for VS Code, the Jest extension is unable to parse the list of tests files because of Turborepo's log prefix.

In the reduced test case, the VS Code settings file configures the Jest extension to access Jest via Turborepo:

.vscode/settings.json:

{
  "jest.jestCommandLine": "yarn run turbo run test --"
}

To generate the list of test files, vscode-jest will invoke the specified command, appending --listTests --json, resulting in the following output:

$ TURBO_UI=false yarn run turbo run test -- --listTests --json
• Running test
• Remote caching disabled
test: cache hit, replaying logs c649256b92a71f6f
test: ["/Users/oliver/Code/reduced-test-cases/turbo-vscode-jest-2/src/add.test.js"]

 Tasks:    1 successful, 1 total
Cached:    1 cached, 1 total
  Time:    56ms >>> FULL TURBO

The test: prefix breaks the Jest extension's ability to parse the JSON list of files.

Actual: tests do not appear in test explorer (sidebar).

image

Expected: tests should appear in test explorer (sidebar). Here's what it looks like with the workaround (--log-prefix=none):

image

Expected Behavior

It's possible to workaround this issue using --log-prefix=none, however I understand that by default Turborepo has some heuristics for when it should automatically disable the log prefix, so it would be useful if Turborepo could extend these heuristics so it works out of the box with VS Code's Jest extension.

To Reproduce

  1. Clone the repository.
  2. Run yarn to install dependencies.
  3. With the Jest extension installed, open the folder in VS Code and navigate to the test explorer and/or a test file.

Additional context

No response

chris-olszewski commented 4 months ago

Hi @OliverJAsh, we currently only disable this for when we detect we're running in Github Actions. I would be happy to accept a PR that does the same thing if we're invoked via this plugin.