zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.83k stars 3.15k forks source link

Detect and swap test runner jest, node:test, & bun:test #21132

Open versecafe opened 6 days ago

versecafe commented 6 days ago

Check for existing issues

Describe the feature

The test button next to tests while very helpful in JS/TS always uses jest in the command leading to it breaking if using the node, bun, or vitest test runners , with jest being the legacy option and with there being multiple options either detection and swapping of runners or a config based test command syntax would make the feature useable in modern TS codebases

Environment

.

If applicable, add mockups / screenshots to help present your vision of the feature

.

osiewicz commented 5 days ago

We're sorta capable of doing this already with toolchains and extra task variables in config. We could try to detect test runner or fall back to an explicit choice made by user. One caveat with it is that toolchain detection currently works at worktree granularity, which would make e.g. detecting different test runners for different subdirectories of a worktree a bit tricky.

mheidinger commented 3 days ago

Something that also could be added with such a detection could be locating the right config file for a given test. E.g. if a test is executed in a sub-package of a mono-repo, the tooling may need the correct config file of the sub-package provided.

This is something that the VS Code Jest Runner extension is already doing today (and I replicated in Bash to make the test runner work in Zed w/ a custom task).