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

Allow to interrupt test running in watch mode #3612

Closed
4 tasks done
sethreidnz opened this issue Jun 19, 2023 · 3 comments · Fixed by #3618
Closed
4 tasks done

Allow to interrupt test running in watch mode #3612

sethreidnz opened this issue Jun 19, 2023 · 3 comments · Fixed by #3618
Milestone

Comments

@sethreidnz
Copy link

sethreidnz commented Jun 19, 2023

Clear and concise description of the problem

Currently if I have thousands of tests to run and want to use the watch feature to filter only say one test, or test file, then I have to wait until the entire test suite runs to then press "h" and do that. This takes a lot of time and also is different to how Jest works where you can interrupt the test running and do filtering.

Suggested solution

Pressing enter, or any of the keys like "h" or whatever should interrupt the current run. That way I could start the watch, press enter, then start filtering to the tests I care about. This is how Jest works and it would be great if Vite did similar.

Alternative

No response

Additional context

No response

Validations

@AriPerkkio
Copy link
Member

This should already be implemented by #3163. When you press c, space or any other key that Vitest registers in watch mode, the test run should be interrupted. Exactly as in Jest.

The h key is not used by Vitest at all.

const keys = [
[['a', 'return'], 'rerun all tests'],
['r', 'rerun current pattern tests'],
['f', 'rerun only failed tests'],
['u', 'update snapshot'],
['p', 'filter by a filename'],
['t', 'filter by a test name regex pattern'],
['q', 'quit'],
]
const cancelKeys = ['space', 'c', ...keys.map(key => key[0]).flat()]

if (ctx.runningPromise) {
if (cancelKeys.includes(name))
await ctx.cancelCurrentRun('keyboard-input')
return
}

@sethreidnz
Copy link
Author

This should already be implemented by #3163. When you press c, space or any other key that Vitest registers in watch mode, the test run should be interrupted. Exactly as in Jest.

The h key is not used by Vitest at all.

const keys = [
[['a', 'return'], 'rerun all tests'],
['r', 'rerun current pattern tests'],
['f', 'rerun only failed tests'],
['u', 'update snapshot'],
['p', 'filter by a filename'],
['t', 'filter by a test name regex pattern'],
['q', 'quit'],
]
const cancelKeys = ['space', 'c', ...keys.map(key => key[0]).flat()]

if (ctx.runningPromise) {
if (cancelKeys.includes(name))
await ctx.cancelCurrentRun('keyboard-input')
return
}

Oh cool. Will have to see when at the computer when I get there if we are on an older version but wasn’t working for me today and very recently migrated. Although that PR looks like it’s pretty newly merged so maybe I’m not on that version.

And yeah it does use “h” it’s what it says at the end when you’ve finished running tests. Something like press “h” for help.

@AriPerkkio
Copy link
Member

it does use “h” it’s what it says at the end when you’ve finished running tests

Oh right, sorry, you are correct. The #3618 adds h key for cancelling watch mode too.

@sheremet-va sheremet-va added this to the 0.32.2 milestone Jun 19, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants