-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Use of Jest CLI in Node scripts #3737
Comments
There is an onComplete event that isn't expose to |
That would work, and yeah, I can put up a PR. I'm thinking, if you pass |
@eldarshamukhamedov This is the |
@rogeliog Yep, I got eldarshamukhamedov@931927f, just need to write the tests. |
Awesome, I left some comments |
Did this get implemented? |
No. Feel free to send a PR 🙂 |
I'm also facing this issue. I'm using I checked out the source code and looks like there is no event / callback as of now which notifies the complete of test execution. If this is a open issue - Is there a workaround? It's said above that we can spawn a new process, but I'm new to Node and need some help in figuring out how to achieve that. To fix this issue, is the approach taken here still correct ? |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hey all, hopefully someone can help me out with a less common use case for Jest. I am writing a set of build/deploy scripts that start by running Jest, before continuing to compile and dockerize an application. Unfortunately, there does not appear to be a public API to match Jest CLI functionality. How can I run Jest from a Node script?
I did find an example in Create React App's test script. The problem with this approach is that
jest.run()
spawns a new process. This process will exit cleanly if all tests pass, and errors out if some tests fail. That's good enough for a CLI command, butjest.run()
does not return a promise, or event stream, so there's no way to detect when and how the Jest process exits from my code.The workaround I'm currently using is to spawn a new process that runs Jest. Since I control how the process is spawned, I can wrap it in a promise that rejects/resolves based on the Jest process exit code. This feels a bit clunky, since I am spawning a process for my build script that immediately spawns another process for Jest. Is there a better way? Is there documentation that I missed?
The text was updated successfully, but these errors were encountered: