While working on a larger web application with an increasing amount of JavaScript code, we did a brainstorming session on how to improve code quality.

One of the first ideas was to introduce unit tests. This will be a long term goal; that will not, however, fix the most common causes of regression: the changing DOM and browser specific issues.

Unit tests run in a mocked, DOM-less environment and are not on the page.

What I'm looking for is an assertion framework that can be plugged into the code like this:

```
var $div = $("div.fooBarClass");
assertNotEmpty($div);
$div.fooBarAction();

```

I've found assertion frameworks that can do this, but they all either log into the console or into the DOM or open a silly pop-up. None of these work together with (thousands of) automated tests.
**What I'm looking for is a run-time assertion framework that logs failed assertion via AJAX!** Ideally, it should be:

* Have common assertions built-in.
* Integrate with JQuery modules, closures.
* Log (via Ajax) the assertion, the file name, the page, [line number](https://stackoverflow.com/questions/1340872/how-to-get-javascript-caller-function-line-number-how-to-get-javascript-caller-s), the cause of failure, some pre-configured variables of the environment (browser, release version etc.).
* **Support callbacks in case of failures. (If any assertion framework can just do this, I would be gladly willing to write callbacks doing the Ajax part.)**
* Work well with all browsers.
* Trivial to exclude from production release.
* Maintained code base.