-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Jest preview not working with Nx monorepo #126
Comments
Hi @srosato. Thank you so much for your interest in Jest Preview and your efforts to report a bug, prepare a reproduction, and even a Pull Request! We know that Jest Preview might not work well with monorepo architecture at the moment. The reason is just that Jest Preview is still very young. We plan to support it soon. But as you provided us an example in #125. I believe the support will come earlier.
I haven't ever had any issue with file watching (using
Yes please. We would like to have you contribute on this. I think Bonus: |
cc: @ntt261298 |
Hi @srosato
|
For sure thanks for the quick replies!! I am quite busy at the moment so I haven't had much chance to come back to it, but I want to, because right now I am daily in this monorepo of mine writing tests. Give me a few days I will come back to it, it is quite obscure to me still. Your library is a godsend guys though - writing tests using React Testing Library without any visual cues is madness. It works super well on projects without Nx, but fair note, my Nx project is quite large so I might have messed a couple of things. |
@srosato Hey Steven. We are able to reproduce your issue and we fix it in Tips: Your PR #125 is merged. You can verify by your example also. More context: |
@srosato Do you experience any bugs (other than the automatic refresh) with Jest Preview always using |
This issue has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from issues that are unactionable. Please reach out if you have more information for us! 💪 |
@all-contributors please add @srosato for bug |
I've put up a pull request to add @srosato! 🎉 |
@nvh95 So sorry for the long delay, I have been swamped with work and did not setup my notifications correctly. I will try out the new version now. |
@nvh95 Ok I have tested on my nextjs-nx example using I updated However, I then went away with my normal routine to run a single test using IntelliJ and this is where I noticed that the node_modules folder gets created within the my-app instead of the project root. I went on the example project and ran the test with IntelliJ (Webstorm) to see the same problem happening. Here is a short video recording: Screencast.2023-06-01.11.12.34.mp4I have yet to dig out why it does this but this is what I got so far. Note: I ran I rebased my example branch with main and have added a few things to my example branch here: main...srosato:jest-preview:nextjs-nx-example. The command that gets run in the preview video is That might be a separate issue though. I do not want to make any promises because last time I vanished (really sorry 😓), but I want to take a look into it when I get the time because I run single tests all the time instead of watching them |
Closing issue as it is fixed. Created a separate issue for Webstorm/IntelliJ problem -> #301. |
Describe the bug
Running a jest preview on a nx monorepo does not benefit from automatic refresh on test failures. The furthest I was able to make it work is by refreshing manually the page, but I do not get any automatic refresh. I attempted to create a reproduction repository by adding an example project.
To Reproduce
Expected behavior
We should see a preview of the HTML output for the test contained within
examples/nextjs-nx/apps/app/specs/index.spec.tsx
Environment
Additional context
I will paste what I wrote on Discord, if that could help in any way
Chokidar seems inconsistent with its file watching. I could only achieve reliable file watching by removing the PUBLIC_CONFIG_PATH + adding usePolling: true to the watcher. I run on Linux (popOS 22.04). I have a feeling chokidar has inconsistent watch issues because I was not able to consistently watch for files changes when the debug function was writing the files. Have you guys ran on inconsistent watch issues? I was running a single jest test with a single test failing. I wonder how inconsistent it would become once I use a more intensive workflow (I use WallabyJs that will very often test files)
Since I am using an Nx monorepo, I run jest tests for one app within apps/app1 and the debug() (or auto preview) will output cached files within [project_root]/apps/app1/node_modules/.cache. The problem with the monorepo is that usually there will be one jest.config.js per app/library but the repo has a single package.json file and I run yarn jest-preview on the root of the project, and therefore the preview server assumes [project_root]/node_modules/.cache. I saw that the CACHE_DIRECTORY on previewServer.js and CACHE_FOLDER on the distributed file are hardcoded at the moment. I can contribute if you want, just wanted to get your opinion on how best you would implement changing cache folder directory (automatically detected or through an option at test setup?)
The text was updated successfully, but these errors were encountered: