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

feat: Add support for watch flag #44

Merged

Conversation

marcoSven
Copy link
Contributor

This commit introduces a feature to support the watch mode in neotest. In the previous implementation, the user had the ability to run tests but there was no provision to watch the files and run the tests when changes occur. This feature is particularly helpful while doing test-driven development where code changes frequently.

  1. Added key mappings examples in README.md to trigger watch mode.
  2. Refactored the build_spec function in init.lua to support watch mode. It now includes command flag "--watch=false" in the command list instead of --run.
  3. Added a new function stream in util.lua which continuously reads file data and triggers a callback function for new data. This is used to watch the test files and run tests on file change.
Screen.Recording.2024-02-27.at.18.25.37.mov

closes #27

This commit introduces a feature to support the watch mode in neotest. In the previous implementation, the user had the ability to run tests but there was no provision to watch the files and run the tests when changes occur. This feature is particularly helpful while doing test-driven development where code changes frequently.

1. Added key mappings examples in README.md to trigger watch mode.
2. Refactored the build_spec function in init.lua to support watch mode. It now includes command flag "--watch=false" in the command list instead of --run.
3. Added a new function stream in util.lua which continuously reads file data and triggers a callback function for new data. This is used to watch the test files and run tests on file change.

closes marilari88#27

Signed-off-by: marcoSven <[email protected]>
@marilari88
Copy link
Owner

@marcoSven Big thanks for your contribution! I left a couple of comments for you. One concern though: I noticed when testing the PR that the vitest process in watch mode sticks around until Neovim shuts down or Neotest stop is called. This could lead to a bunch of unwanted background processes if we're running lots of tests in watch mode. How do you handle it?

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
lua/neotest-vitest/init.lua Show resolved Hide resolved
marcoSven and others added 2 commits February 28, 2024 16:25
Co-authored-by: Marco Ilari <[email protected]>
Co-authored-by: Marco Ilari <[email protected]>
@marcoSven
Copy link
Contributor Author

I noticed when testing the PR that the vitest process in watch mode sticks around until Neovim shuts down or Neotest stop is called.

I think this is the same with the Jest adapter.

@marilari88
Copy link
Owner

@marcoSven thanks!

@marilari88 marilari88 merged commit ae77428 into marilari88:main Feb 29, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for the --watch flag
2 participants