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

deno test --watch should always print the full test output #24625

Open
KnorpelSenf opened this issue Jul 17, 2024 · 4 comments
Open

deno test --watch should always print the full test output #24625

KnorpelSenf opened this issue Jul 17, 2024 · 4 comments
Labels
--watch related to the watch feature of the CLI feat new feature (which has been agreed to/accepted) testing related to deno test and coverage
Milestone

Comments

@KnorpelSenf
Copy link
Contributor

When running a suite of tests with deno test --watch ./tests/, all tests are run initially. As soon as a file is changed on disk, only the affected tests are re-run. This is great.

What is less great is that the output is now trimmed down to only the tests that were executed. This means that I lose the overview over all tests as soon as I touch one of them. I have to either cancel the watch mode and start it again, or manually save a bunch of unchanged test files to slowly reveal all output again.

Consider the following workflow:

  1. Run all test in watch mode
  2. See that two test files each have a failing test
  3. Fix the first test, triggering a re-run
  4. [Now I want to see all tests again to find out where the second test was failing]
  5. Fix the second test
  6. [Now I want to be sure that the entire test suite is green]

I suggest to keep the output from previous test runs in memory and to merge it with the new output. This would combine the best of both worlds: only affected tests are run, and the output of deno test --watch still reveals the results of the entire test suite.

@MKRhere
Copy link
Contributor

MKRhere commented Jul 17, 2024

As it is currently, when tests update, the report fails to give me the big picture of where all my tests are. It'd be cool if I can always see all test results. Failing that, if you want to keep output relevant to currently affected tests, at least keep the final counter overall, so I can glance at overall stats.

@bartlomieju
Copy link
Member

This seems very reasonable. We might not have bandwidth to work on this for the next few weeks, but I'm more than happy to accept contributions.

@bartlomieju bartlomieju added feat new feature (which has been agreed to/accepted) testing related to deno test and coverage --watch related to the watch feature of the CLI labels Jul 17, 2024
@HasanAlrimawi
Copy link
Contributor

HasanAlrimawi commented Sep 16, 2024

@bartlomieju
Upon investigation,
I noticed that every test report is done by a thread with no persistence over the test results (results are generated and consumed on the same thread).
Then upon any change on any file, a new thread will be spawned to take responibility of reporting the same way. In short, it seems there isn't any mechanism to hold the tests records.

Approach I have in mind: How about passing through mutex wrapped struct that will be updated by every thread in order to keep overall statistics over all the files tested?

Is this an acceptable approach or is there a better approach that's maybe already used somewhere in the code base that you may suggest?

@bartlomieju bartlomieju added this to the 2.1.0 milestone Sep 16, 2024
@marvinhagemeister
Copy link
Contributor

+1 for moving reporting out of each individual thread to a central place. That would also allow us to print out test coverage information at the end and stuff like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
--watch related to the watch feature of the CLI feat new feature (which has been agreed to/accepted) testing related to deno test and coverage
Projects
None yet
Development

No branches or pull requests

5 participants