code-dot-org/blockly — pull request #393 by Bjvanminnen (2014-02-10 21:11:06+00:00)
Title: Run each level test in own process

This makes it so that for each of our level tests we spawn a new node process, and execute the puzzle code in it. This means we no longer need to worry about leaking global data between tests, and more accurately reflects what happens on the live site. It also allowed me to pull out some hacks I had that tried to reset global data between tests.

One particular problem I was trying to solve was that tests run later in the suite were running much slower than those at the beginning. It turns out the reason why is that each test would add a set of global event listeners. This meant that when an event fires on test 50, for example, it ends up going through all 50 event handlers. The time to run all the tests hasn't change significantly, as there is a cost to spawning a new process each time, but the execution time of each test should no longer change depending on how many tests were run before it.