mirror of
https://github.com/chaijs/chai
synced 2024-11-16 00:28:03 +00:00
22 lines
390 B
JavaScript
22 lines
390 B
JavaScript
/*!
|
|
* Attach chai to global
|
|
*/
|
|
|
|
window.chai = require('chai');
|
|
|
|
/*!
|
|
* Provide check for fail function.
|
|
*/
|
|
|
|
window.err = function (fn, msg) {
|
|
try {
|
|
fn();
|
|
throw new chai.AssertionError('Expected an error');
|
|
} catch (err) {
|
|
if ('string' === typeof msg) {
|
|
chai.expect(err.message).to.equal(msg);
|
|
} else {
|
|
chai.expect(err.message).to.match(msg);
|
|
}
|
|
}
|
|
};
|