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

Fix concurrent tests #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

cwalther
Copy link
Contributor

When running node_modules/.bin/jest (which is my current guess at the right way to run tests, see #77), it tries to run both test suites in parallel, but randomly ends with one of them passing and one being stuck at RUNS until Jest times out after 500 s.

The reason seems to be that both suites try to run a server on port 3000. Only one can succeed, and will subsequently supply files for both. But when the suite that succeeds at starting the server is also the one that finishes first, it will take down the server at that time and leave the other one hanging, sometimes when it’s still trying to load tests from the server, sometimes when it tries to close() its own nonexistent server. (I didn’t completely study what happens in the latter case, I suspect there may be some exceptions/rejections involved that don’t make it to the console output.)

The attached commit fixes this by running the two servers on different ports. With that, both suites now pass for me. (They take a long time though. Are all these waitFor()s really needed? The Puppeteer readme says “There’s no need for evil “sleep(1000)” calls in puppeteer scripts”.)

Maybe there would also be a way of solving the problem using one server for both suites that is closed when all are done, but I’m unfamiliar with Jest and don’t know.

Running jest runs the two test suites in parallel. If both try to run a server on port 3000, only one of them will succeed and supply files for both, however when that suite finishes first, it will take down the server and leave the other one hanging. Fix this by running the servers on different ports.
@cwalther
Copy link
Contributor Author

Rebased on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant