Skip to content
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

[Feature request] Ability to just run the last changed test file #119

Closed
jackfranklin opened this issue Jun 8, 2017 · 12 comments · Fixed by #674
Closed

[Feature request] Ability to just run the last changed test file #119

jackfranklin opened this issue Jun 8, 2017 · 12 comments · Fixed by #674

Comments

@jackfranklin
Copy link

Just had a case where I was working on file foo.js and foo.spec.js. Foo is used in a bunch of places, so upon changing it Jest correctly figures out that it has 10 spec files that it should run. This is great most of the time, but it means that I have to wait longer to know if foo.spec.js has passed or not. An option to turn on a "single file" mode where it only runs the last changed spec file on each change would be quite useful.

I'm quite happy to attempt some work on this if you think it's a reasonable addition :)

@orta
Copy link
Member

orta commented Jun 8, 2017

Yep, sounds good to me.

This would need to be something where the extension itself controls what test is being ran, which it currently doesn't. It'd require turning off it's --watch process and starting to handle it's own, very feasible.

@jackfranklin
Copy link
Author

Probably something that you'd want to be able to trigger via the command window, so alongside 'Jest start watching' + 'Jest stop watching' you might have 'Jest run last test file mode' or something better worded !

I'm very new to VSCode + extensions but I'll try to start hacking something soon.

@orta
Copy link
Member

orta commented Jun 8, 2017

Yeah, makes sense, and maybe add a clickable button on the bar to turn it off:

screen shot 2017-06-08 at 18 56 56

@orta
Copy link
Member

orta commented Oct 4, 2017

I've been having a think about this: I'd like the ability to toggle on a single file mode on the watcher - perhaps this could be an action button in the top right (orta/vscode-react-native-storybooks#26), which closes the current watcher and a version of the watcher that includes a suffix of the filepath.

@seanpoulter
Copy link
Member

I love the idea of being able to run one file. If we wanted to be able to test the unsaved changes to the document, we'd need to be able to test just one file first.

The other option we may not have explored yet is setting up our own reporter to stream tests results as they happen with IPC.

@goodbomb
Copy link

Any updates on this?

@seanpoulter
Copy link
Member

seanpoulter commented Feb 20, 2018

Yep, @goodbomb. I've been spending my spare time settling into a new job so I haven't had the bandwidth to review @marcinczenko's changes to PR #215. It's the blocking change to resolve this issue, so if you've got the time I'd appreciate a second set of eyes or help with some integration tests to make sure we're preserving the existing behaviour. On the PR @orta mentioned he may have some time, but with 1.7k lines added he may want some help.

@haroonKhan-10p
Copy link

+1

@seanpoulter
Copy link
Member

@marcinczenko's PR has been merged if anyone wants to have a go at a PR.

@connectdotz
Copy link
Collaborator

after 3 years, we finally added this feature... Please feel free to give v4.0.0-alpha.5 a try and let us know if it works for you.

@sneko
Copy link

sneko commented Jan 31, 2023

@connectdotz I read multiple times https://github.com/jest-community/vscode-jest/blob/master/README.md#how-to-trigger-the-test-run and I'm able to turn off the autorun, but as mentioned in the original post I'm looking for running only the last file/test that has changed.

By default --watch will run all uncommitted test files, I'm looking for option to say "let's focus just on last changes". Is it possible?

EDIT: see the solution https://stackoverflow.com/questions/75303569/how-keep-tests-shortcuts-icons-once-auto-run-is-switched-off-from-the-extensio/75303812#75303812

@connectdotz
Copy link
Collaborator

@sneko, the default autoRun is to run only changed files (the watch mode). Did I miss something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants