caolan / nodeunit

Easy unit testing in node.js and the browser, based on the assert module.
MIT License
1.9k stars 370 forks source link

Inject custom assertions to types.js by publishing assert in types.js #211

Open ronnen opened 11 years ago

ronnen commented 11 years ago

I would like to add custom assertion so it can be used similarly to test.equal (e.g. test.contains).

The issue is that assert is required in two places: In nodeunit.js, and in types.js.

The assert in nodeunit is exported, the one in type is not. If this could be exposed then it would be very easy to add a custom assert and let the mechanism add them to test with the necessary wrapAssert. Without it, it's still possible to use custom assert but cannot add them to the test level.

Thanks.

Ronnen

hypesystem commented 10 years ago

Related to this, it would be interesting to know what the policy is towards assertions in general: do you plan on adding more, or are we to make do with the existing ones?

I would like a test.contains, too, but if it clashes with your ideas I will keep using test.ok(arr.indexOf(val) !== -1).