cannot get containEql and throwError to work with rtd
AdrienLemaire opened this issue · comments
Hello,
I created this issue #124, but it might actually be a problem with should. I'd really appreciate if you could check it out :)
The problem is that some very basic tests with should work, but when I try to do a containEql or throw/throwError, it fails without any traceback (and debugging the values doesn't raise any alarm, they look good).
Any idea why this is not working ?
Thank you for your help!
From your example:
Bitcoin.verify_adress(data.adress).should.throwError();
There is simply function call, not a function which throwError expect to call.
Bitcoin.verify_adress(data.adress)
execute function, which result you pass to .should.
I think you'd expect something like this:
Bitcoin.verify_adress.bind(Bitcoint, data.adress).should.throwError()
.bind will return function, and throwError call it and check on errors
hmm I see, I didn't understand that :)
What is Bitcoint in your example ?
I tried:
Bitcoin.verify_address.bind(null, @data.address).should.throw "Address not base58"
But I get
PhantomJS 1.9.0 (Linux) the Bitcoin model verify_address returns a 601 error if address is not base58 FAILED
TypeError: 'undefined' is not a function (evaluating 'Bitcoin.verify_address.bind(null, this.data.address)')
I also wonder if it's possible to verify that the error thrown has the correct code 601 (cf Meteor.Error ).
Thank you for your help @btd!
Bitcoin
from issue you gave link.
Please post full test code, that i do not search by issues what is going on.
throwError expect that any error inherits from standard Error function and use standard properties of this object like message. E.g. if Meteor.Error is Error you can check message with .throw(/601 error/) (it can be regex, string or error type)
hmm I can get my test to pass as follow:
(->
Bitcoin.verify_address @data.address
).should.throw()
But it fails with the weird TypeError undefined error when I try to speficy the error message to throw (whatever I throw, a Error or Meteor.Error). Quite annoying, as I wanted to test the different errors thrown.
The other should issue was with containEql. When I test the example given in the doc:
[{a: 'a'}, {b: 'b', c: 'c'}].should.containEql({a: 'a'});
I get:
TypeError: 'undefined' is not a function (evaluating '[
{
a: 'a'
}, {
b: 'b',
c: 'c'
}
].should.containEql({
a: 'a'
})')
Any idea why this doesn't work as expected ? Might that be something to do with Mocha and not should ?
Looks like a bug, which version do you using and how include script (which and where)?
npm list returns should@2.1.1
My stack is: RTD -> Karma -> Mocha -> Chai -> Should
Chai is making should available directly, so I only configured the karma.conf.js
as follow:
frameworks : ['mocha', 'chai'],
client: {
mocha: {
ui: 'bdd'
}
},
Therefore, it might be using the should version of chai and not the should I npm installed ?
You can test it with:
$ git clone https://github.com/Fandekasp/CoinsManager.git
$ cd CoinsManager && git checkout feature/rtd_tests
$ sudo npm i -g karma phantomjs istanbul grunt-cli selenium-webdriver mocha karma-chai should
$ cd test/rtd && grunt --debug
Are you sure that you are not using chai version of .should
?
Also .containEql
was added at 3.*
version of shouldjs
yes, must be it... I'll look more into it tomorrow, thank you :)