-
-
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
Workers in parallel worker pool should have JEST_WORKER_ID assigned in ENV #2284
Comments
Feel free to send a PR for this. I don't think worker-farm supports the notion of ids but you can add the state in |
@evantahler are you interested in implementing this? |
Sadly no. We've gone back to Mocha as there were a few other problems with Jest which didn't work for ActionHero. |
Sad to hear that 😞. If you have some time to point out what we could make better, please file a new issue for that. Feedback is always welcome! |
Are there any ideas around this topic to get a unique identifier, preferably sequential starting at 1 like @evantahler suggested? I'm running into the same problem/use-case. I'm spinning up multiple servers to do integration tests to a DB and each needs to be on a unique port. Currently I'm playing with this idea:
The problem here is the race condition that the same port number will be reported as free to two or more workers. Being able to do something like:
would solve this. @cpojer Is this the new location of the file that launches the workers? https://github.com/facebook/jest/blob/d1cb3959f11331f432354f1607025d60ef0667bf/packages/jest-runner/src/run_test.js Could a local module counter be incremented in here that is passed to each new worker? |
This would be so helpful, we're having the same issue as @guyellis |
I like the idea, worker classes wrapping child processes are internally stored in an array, getting each a positionary id; so it shouldn't be hard to add an extra variable. The relevant code can be found here, for the worker instantiation and here, for the process spawn. I'd be more than happy to accept a PR implementing it 🙂 |
Hey @mjesun |
Go for it 🙂 |
@ranyitz can't assign you, but I picked it so others don't re-pick it. Feel free to implement it, and thanks for the contribution! |
Since @ranyitz merged this feature I've been using it and it's great - thank you for doing that! Currently using Jest I'm going to try and reproduce this issue. Before creating an issue for this has anybody else noticed this? |
Here is a super simple repo that shows the unexpected output in the Readme. Strange thing is that when I first created that repo I was getting the expected output with the values of 1 and 2 for the |
I've filed an issue at #6608 |
Responding back to #2284 (comment), Actionhero (and related projects) now use Jest! Jest is also a great way to text node server apps too! |
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. |
Hi!
Jest is cool. Thank you for all your hard work! I'm porting ActionHero's test suite to Jest, as some of the features you have (
--watch
, parallel execution, etc) make testing much better.ActionHero is a server-side node.js project, and many of our tests rely on interacting with a database (Redis for us). To fully isolate our tests, we need to boot the server on unique ports and have separate databases for each test to work against. This allows tests to run in parallel and not pollute each other.
We can try to derive a unique ID for each worker in the pool via the PID, IE:
let id = process.pid % require('os').cpus().length
, but you sill may end up with collisions.If each test-running worker was assigned a unique ID from the parent like
process.env.JEST_WORKER_ID = 1
, that would make this possibleThe text was updated successfully, but these errors were encountered: