docson icon indicating copy to clipboard operation
docson copied to clipboard

Fix concurrent tests

Open cwalther opened this issue 5 years ago • 1 comments

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.

cwalther avatar Sep 23 '19 10:09 cwalther

Rebased on master.

cwalther avatar Sep 24 '19 13:09 cwalther