zed icon indicating copy to clipboard operation
zed copied to clipboard

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

Open versecafe opened this issue 1 year ago • 4 comments

Check for existing issues

  • [X] Completed

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

.

versecafe avatar Nov 24 '24 07:11 versecafe

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.

osiewicz avatar Nov 24 '24 13:11 osiewicz

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).

mheidinger avatar Nov 27 '24 09:11 mheidinger

Is this a duplicate of https://github.com/zed-industries/zed/issues/12828?

dlindenkreuz avatar Jan 24 '25 11:01 dlindenkreuz

https://github.com/zed-industries/zed/pull/31711 helps with a part of this and can be improved by the future PRs if needed.

SomeoneToIgnore avatar May 29 '25 23:05 SomeoneToIgnore

@mheidinger right now it just puts mutliple options in when you click the test runner if for example jest and vitest are both detected in the package.json I'm opening a PR for node:test and bun:test support today which relies on the presence of @types/node or @types/bun but given that it's common to have a bun or node types with a dedicated test runner such as vitest I've put them in order so bun or node test runners show up below a dedicated test running package in the small menu that appears and in the task runner.

versecafe avatar Aug 29 '25 23:08 versecafe