kriskowal/asap — pull request #15 by domenic (2013-07-27 20:33:33+00:00)
Title: Completely overhaul the tests.

Thanks so much to @rkatic for setting up the basic infrastructure and test cases for what we want to test. Here's my attempt to kick things up a notch and make them easier to maintain going forward.

---

- Use zuul for automating the HTML page generation and browserifying.
- `npm test` now runs `npm run node-test`, which is just Mocha in Node, and `npm run phantomjs-test`, which uses zuul to run in PhantomJS.
- `npm run browser-test` uses zuul to set up a server on 8080 that you can test at; it re-bundles the files each request.

- Add settable `asap.onerror` to which uncaught errors can be forwarded.
- This allows trapping full error objects, not just error messages (`window.onerror` can only do the latter).
- It also fixes all browser-compat problems with `window.onerror`.
- It allows us to test asap directly, instead of a wrapped version of asap whose errors are trapped and put elsewhere.

- Rewrote tests to be straightforward and imperative.
- No more custom microsyntax for writing the tests.
- No more 187 lines of prelude before actually getting to the tests.
- Tests now set up a task graph explicitly, then compare the call order and/or exception order to the expected order.

- Added a very rudimentary browser shim for the domain module.
- Uses `asap.onerror` to record any errors.
- Allows the test code to look the same in both Node and the browser.
- Centralizes browser and Node.js divergences in a single file and single abstraction.

- Removed expect.js dependency in favor of the built-in assert module.