-
Notifications
You must be signed in to change notification settings - Fork 293
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
Automatically rerun tests after updating snapshots. #179
Comments
I am working on pull-request for that. Unfortunately, the way the jest process management is done is a bit hard to follow for me. As soon when start playing with starting/restarting/stopping jest process and you want to fill in control some things needs to be simplified/corrected. Especially, making In the meantime, you may like to check: and and let me know if this ok. |
Is it possible to update the snapshots and run all tests like you're hoping to using the interactive watch mode @marcinczenko? I've been experimenting with sending commands to Jest over |
Related: There's also discussion in Jest around having a JS API for running a test, which could mean that some of this process faffing could be simplified: jestjs/jest#5048 (comment) |
@marcinczenko I think you are right that the process management can definitely be simplified and streamlined:
|
Thanks for the input - I will look into it a bit later - I can only be active late in the late evening on it :(. Just a quick reply to @connectdotz. Introducing a proper separate abstraction is definitely what should be done here. So thanks for triggering that! I just took a small step so that I understand myself how it works right now. We have to remember that Jest is not always playing very nice - e.g. it forwards both We also may want to think about naming - isn't I would suggest to separate the two issues: cleaning up the process management, and then doing other stuff like rerunning all tests after updating snapshots. If you agree, I can separate the two issues. As I think I have pretty good understanding of how process work I can work on introducing the two abstractions for process management. Just let me know :). |
We're only running one for now. As we look at getting test results in the editor quicker we'll probably want another Jest process. That'd help test:
I'm all for an issue per symptom. 👍 |
👍
This seems like a bug on the
hmmm... I am not quite sure what you have in mind for JestTask... I thought we already have one, it's called regarding the naming: @marcinczenko your naming suggestion makes sense to me for a single jest process environment. But as @seanpoulter suggested, if we ever going to move toward multiple jest runs, then maybe a more generic naming scheme will be easier to transition to. Either way, once the TaskManager refactoring is done, it should be much easier to introduce Runner pool/queue for multi-jest runs later. |
@connectdotz Perhaps I am missing something, but this looks to me to be a conscious choice:
Yes, that's exactly the reason - it is external dependency that demands its own abstraction on the plugin side.
Hmm...was your proposal already taking into account multiple tasks? Then sorry. You were still referring to Anyway - I have created a separate issue for this (#189), leaving this thread to the comments only about rerunning tests after updating snapshots. I do care to have a more stable plugin, so if you guys need some help please let me know. If you prefer to work on the TaskManager abstractions yourself, it is completely fine with me. I have plenty of work and I would prefer to avoid working on something that you do not value at the moment. |
@seanpoulter, @orta So coming back to rerunning tests after updating snapshots. Does it make sense to create the pull request for the temporary solution I have now. I am using it now, so I kind of achieved what I wanted. It adds a new config option to rerun the tests after snapshot update which is We can work on a better approach in the mean time, but maybe this is already useful to some other people. What's your idea? |
no, the current implementation is definitely for the single process/runner, that's why I was agreeing with your naming suggestion under this assumption. |
Sure 👍 |
@marcinczenko now I have a bit more time to reply: I sensed you are a bit frustrated... please don't, we are all trying to do the right thing to help our favor tool ;-). Not sure if this is the best place to comment these kind of things, but I figure it's better to address them than not...
ouch, if I made you feel that way, it is my bad. It's great that you feel the code should be improved for simplicity and that's why we love fresh perspectives! I am sure there are many ways to refactor the process and it's hard to fully understand each other's idea via these comments... I just want to share the lesson we learned and balance short-term hack vs long-term fix...
Just because the code is out there, doesn't mean its right or unchangeable ;-) when uncertain, I will usually do the backward compatible change, so whoever needs it can get the benefit without breaking others.
I guess it all depends on what this local abstraction needs to do... If it makes more sense to happen in the external package, then we should fix it there (better encapsulation too) instead of hacking on our side, which is exactly what led us to the process management issue now... just trying to learn from our mistake. regarding restarting the process after snapshot update: I see you are trying to call stopProcess() followed immediately by startProcess(). Given stopProcess() will not "complete" right away (like an async operation), the startProcess() should fail to keep the "single-process" mode true. Will it be better to wait after the process is fully stopped before invoking startProcess()? What do you think if we use a promise (or something like that), resolved by debuggerProcessExit, to trigger the startProcess()...? I could be wrong but I think you might not even need to touch the forcedClose or any other part of the system if we can truly serialize the stop/start sequence... |
@connectdotz I moved discussion on this to #189. I will replay to your comments there. |
Environment
node -v
: [v9.0.0]npm -v
: [5.5.1], yarn v1.3.2npm ls react-scripts
(if you haven’t ejected): [fill]Operating system: [[email protected]]
Steps to Reproduce
[Pre-cond]: all tests passing.
Replace them
in the Info box.Updated Snapshots. It will show in your next test run.
.Expected Behavior
Actual Behavior
No tests found related to files changed since last commit. Press
ato run all tests, or run Jest with --watchAll.
In such a case thePROBLEMS
tab still shows failing Snapshot test.It would be nice to get an Option (e.g. via CMD-SHIFT-P) to force re-run all the tests. Otherwise it is hard to clean up the
PROBLEMS
tab and it is annoying. I see there is an enhancement proposed for just doing this, but this is still not optimal solution for a nice snapshot-testing flow.A natural behaviour with snapshot testing is to re-run the relevant tests immediately after replacing snapshots. The
Updated Snapshots. It will show in your next test run.
confirmation is redundant and off-the flow. Also doing 'dummy' save on the file that caused the snapshot failure, hopping to trigger a test rerun is not natural (and it does not always work).Reseting Jest Runner (Stop/Start) will clear the errors in the
PROBLEMS
tab, but it is also not how one would like to go through the process.The text was updated successfully, but these errors were encountered: