-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test runner integration #5242
Comments
@chriskrycho From the design side this is a pretty giant task – A few questions:
FYI we probably won't work on this immediately, just trying to get ahead of design here. |
@iamnbutler sorry for the delay in response—busy couple of weeks!
One additional note: I wouldn’t say it’s truly an MVP hard requirement to have the test runner integrate with debugger tools… but it’s pretty close. Debug-stepping through a failing test is super helpful. |
For me having Wallaby.js is a game changer. |
VS Code with Go has the best IDE testing feedback loop I've ever used. Everything else seems to have difference pieces of the puzzle, for me this includes the following:
And then the following are the game changers, that I don't think fit into a minimal feature set, but let me move faster:
I found line highlighting of test coverage much easier to grok that gutters. That might be a matter of preference between engineers, like debug-stepping which I've never found helpful. I think most languages and frameworks can be supported without much extra work, if you're able to build on VS Code's Testing API (like the LSP). |
I believe Spacemacs has a pretty minimalistic approach
It would probably save some time on adding the whole UI with test selection pane including checkmarks and buttons. This minimal set of features enables quick test driven development:
|
Also, the ability to navigate between tests and test subjects. In intellij, this is cmd-shift-t. It bounces you from the source file to the test file and vice versa. If the destination file is already open, moves you to that tab. |
The minimal keyboard-driven set of features that @tomekowal mentions are the only ones that I even care to use, so that's what I'd love to see as well. But really anything that makes it a little more possible to run a given test would be a welcome addition. As of right now the closest I've found is |
I mentioned this before in #4913 but it would be great to be able to define my own keybindings to run 1. all tests in the current file 2. only the test currently focused on 3. all tests of the project. In VSCode, I achieve this with custom |
One of my favorite features in Goland (IntelliJ) is that there isn't just top-level test integration, but per case integration if you are using table tests. I haven't seen that in VS Code, but maybe there's some plugin for it. That makes it even easier to run just an individual test by clicking the run icon in the gutter. |
For VSCode I'm using https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest for Jest tests. Well, it works. And has useful view of tests with links to each test location. Might be something for inspiration. |
For those waiting for a proper test runner. I was able to work around it using commands in zed preview:
and then in
That makes the issue less relevant for me. |
Thanks for the suggestion. Managed to get vitest to test the current file on a simple keybind.
Then you can just bind the "Test current file" task as you mentioned above. |
I've found a way to easily run my tests. I can run tests from a file or directly from the test file. For example, if I run the script inside the Then I created a shortcut to run the tests by simply pressing The script is located at .zed/ folder in my project workspace, so I can easily adjust the script to other languages or projects in the future.
#!/bin/bash
filename=$ZED_FILE
dirname=$(dirname $filename)
basename=$(basename $filename)
cmd=pnpm
function makeArgs() {
args=(run test --detectOpenHandles --silent=false --verbose $1)
echo "${args[@]}"
}
base=${basename%.*}
base=${base%\.test}
base=${base%\.spec}
base=${base%\.e2e-spec}
for ext in e2e-spec.ts spec.ts test.ts; do
if [ -f $dirname/$base.$ext ]; then
echo $dirname/$base.$ext
$cmd $(makeArgs $dirname/$base.$ext)
exit $?
fi
done
pnpm run test --detectOpenHandles --silent=false --verbose $dirname
exit $?
[
{
"label": "Test",
"command": "$ZED_WORKTREE_ROOT/.zed/test.sh",
"use_new_terminal": false,
"reveal": "never"
}
] For the shortcuts, I'm using this (note that I use Vim, so you may need to change the context): {
"context": "VimControl && !VimWaiting && !menu",
"bindings": {
"space r t": ["task::Spawn", { "task_name": "Test" }]
}
}
|
If this helps anyone this is how I got it working with RSpec (Ruby): {
"label": "RSpec",
"command": "bundle exec rspec",
"args": ["$ZED_FILE:$ZED_ROW"],
"tags": ["rspec-test"]
} |
Here is my solution for just one test in Rust. Select the test-fn´s name and then it runs the selected test. Unfortunately it does not recognize if several tests are selected with a multiselection.
and in keymap.json:
|
Just to update this issue for any users who haven't been in Zed for awhile - we now have the ability to run tests in Zed, so long as your language extension provides the plumbing to inform Zed what a test is how to run it. You can run tests under your cursor, and we decorate the gutter with a run button next to the test. What we don't have yet is some test panel that shows all of the discovered tests. |
Can we customize keybindings for this? |
is there is anyway to change the default command in settings for the play button in the gutter? |
@MusaGillani Not to my knowledge, but you can change it in the sources. For example, I made the following local changes to use cargo-limit in Zed: https://gist.github.com/tindzk/4515c859182fa1bb9a0281582e303192 |
Yeah the play button does not work for me because it spawns a new terminal and runs |
How can we configure that? I our mono-repo the entry point is different from the top level package.json and we need to be able to configure it to execute correctly |
Check for existing issues
Is your feature request related to a problem?
Other editors and IDEs (e.g. IntelliJ, Code, Visual Studio, Nova, Xcode, etc.) have the ability to put test results in a panel and often to run specific tests from a gutter indicator as well as the panel. Bonus: showing test results inline.
Describe the solution you'd like
If applicable, add mockups / screenshots to help present your vision of the feature
Here's how VS code presents a test you can run directly inline via the gutter:
And here's its testing panel:
The text was updated successfully, but these errors were encountered: