chai/test/plugins.js
Veselin Todorov 930dfbdc4f Fix an issue with mocha --watch
When running tests with `mocha --watch` the following exception is thrown:

  TypeError: Cannot redefine property: testing

Here is the fix for it. We should be more careful in the future, since the `watch` param is super useful and a lot of developers are using it.
2012-04-29 09:58:56 +03:00

28 lines
569 B
JavaScript

if (!chai) {
var chai = require('..');
}
suite('plugins', function () {
function plugin (chai) {
if (chai.Assertion.prototype.testing) return;
Object.defineProperty(chai.Assertion.prototype, 'testing', {
get: function () {
return 'successful';
}
});
}
test('basic usage', function () {
chai.use(plugin);
var expect = chai.expect;
expect(expect('').testing).to.equal('successful');
});
test('double plugin', function () {
chai.expect(function () {
chai.use(plugin);
}).to.not.throw();
});
});