refute is "assert.not*" assertion library.
It's inspired by busterjs/referee.
npm install --save-dev refute
refute
inherit from assert(Node's Assert).
var assert = require("assert");
var refute = require("refute")(assert);
refute(false);
refute.equal = assert.notEqual.bind(assert);
refute.strictEqual = assert.notStrictEqual.bind(assert);
refute.deepEqual = assert.notDeepEqual.bind(assert);
refute.throws = assert.doesNotThrow.bind(assert);
var assert = require("assert");
var refute = require("refute")(assert);
describe("refute-test", function () {
it("refute", function () {
refute(false);// not true is pass
});
it("refute.equal", function () {
refute.equal("string", "non-string");// pass
});
it("refute.deepEqual", function () {
var obj = {
a: 1
};
var expected = {
b: 1
};
refute.deepEqual(obj, expected);// pass
});
it("refute.throws", function () {
refute.throws(function(){
assert(true);
});
});
});
Integrated with power-assert
You can use refute
with power-assert.
- Change
require("assert")
torequire("power-assert")
- var assert = require("assert");
+ var assert = require("power-assert");
- Add
refute.*
methods to espower's options.patterns.
require('espower-loader')({
// directory where match starts with
cwd: process.cwd(),
// glob pattern using minimatch module
pattern: 'test/**/*.js',
// options for espower module
espowerOptions: {
patterns: [
"assert(value, [message])",
"refute(value, [message])",
"assert.ok(value, [message])",
"assert.equal(actual, expected, [message])",
"refute.equal(actual, expected, [message])",
"assert.notEqual(actual, expected, [message])",
"assert.strictEqual(actual, expected, [message])",
"refute.strictEqual(actual, expected, [message])",
"assert.notStrictEqual(actual, expected, [message])",
"assert.deepEqual(actual, expected, [message])",
"refute.deepEqual(actual, expected, [message])",
"assert.notDeepEqual(actual, expected, [message])"
]
}
});
See espower.config.js and mocha.opts of example.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT