Closed flosse closed 12 years ago
If they throw AssertionError
s they can be thrown right in. Otherwise they need a little bit of glue, we already have several hooks available. Want to take a stab at integrating them?
Both of these throw AssertionError
s, so there's nothing to do to support them. Just add them as libraries in your project and use at will.
There is still WARNING: No assertions!
. Where is my mistake?
buster = require "buster"
app = require "../src/myApp"
chai = require('chai').should()
buster.testCase 'does chai work?',
'hello chai': ->
"a".should.equal "b"
Failure: does chai work? hello chai
expected 'a' to equal 'b'
1 test case, 1 test, 0 assertions, 1 failure, 0 errors, 0 timeouts
WARNING: No assertions!
edit: same problem with should.js
Ah, so Buster will catch the errors, but is never notified of success. That requires a (very small) extension to do. If you don't want to do it, you can silence the error:
buster.testRunner.failOnNoAssertions = false;
However, by doing that you're opting out of potentially very useful information. A better approach would be to create a small buster-chai
extension that pings buster on assertion success.
Are there any docs/tutorials/examples how to create buster extensions? Or could you give me some hints where to start studying the buster code?
buster-chai should be a subset of buster-jstestdriver code. Check that out first. :-) https://github.com/busterjs/buster-jstestdriver
@magnars: thx, I'll have look at it and hopefully I'll be able to write the extension.
@flosse Don't be discouraged by the size of buster-jstestdriver, it does quite a bit more than you need to do. I'm sure @cjohansen can give you a more precise starting point.
Actually, you don't need an extension for this, you only need a wrapper module. This is how buster-assertions integrates with the runner:
var buster = require("buster-test");
buster.assertions = require("buster-assertions");
var assertions = 0;
var count = function () { assertions += 1; };
buster.assertions.on("pass", count);
buster.assertions.on("failure", count);
buster.testRunner.assertionCount = function () {
return assertions;
};
Looking at this I'm not very impressed, to be honest. Should probably just be something like buster.testRunner.countAssertion()
.
Hey buster.js team! Unfortunately I still couldn't find some time to implement an extension. Are the any new changes so far that makes it possible to use chai.js easily?
It would be great if you can use another libs like chai.js or should.js