moll / js-must

An assertion library for JavaScript and Node.js with a friendly BDD syntax (awesome.must.be.true()). It ships with many expressive matchers and is test runner and framework agnostic. Follows RFC 2119 with its use of MUST. Good stuff and well tested.
Other
336 stars 35 forks source link

publish to npm please #30

Closed reharik closed 9 years ago

reharik commented 9 years ago

Hey after considerable difficulty, I have realized that what you have published to npm does not match what is in your read.me file. I'm trying to work with promises which does not work because I do not have the new classes even though I just installed an hour ago. I guess I can just clone your project and include it that way but that clearly is not sustainable. Please publish the new stuff or at least create a branch so when I land on you project I don't read about stuff that is still in dev. Thank you, R

moll commented 9 years ago

Sorry about that. You stumbled upon the slight window where the master branch doesn't match what NPM provides. There are a couple of things to do before cutting a stable release. The README.md inside the module (in ./node_modules/must/README.md) always refers to the version you have and https://github.com/moll/js-must/blob/master/CHANGELOG.md lists what's in master, but not yet released, under the "Unreleased" title.

Let me see if I can somehow cut out an explicit beta release...

reharik commented 9 years ago

so, do you have an eta? Because I need the promise stuff. Thanks for the response. r

On Mon, Jun 15, 2015 at 3:02 PM, Andri Möll notifications@github.com wrote:

Sorry about that. You stumbled upon the slight window where the master branch doesn't match what NPM provides. There are a couple of things to do before cutting a stable release. The README.md inside the module (in ./node_modules/must/README.md) always refers to the version you have and https://github.com/moll/js-must/blob/master/CHANGELOG.md lists what's in master, but not yet released, under the "Unreleased" title.

Let me see if I can somehow cut out an explicit beta release...

— Reply to this email directly or view it on GitHub https://github.com/moll/js-must/issues/30#issuecomment-112190748.

moll commented 9 years ago

Aand done! ;-) Published all of the current changes as v0.13.0-beta1. You should be able to get it by using npm install must@beta.

Let me know if that works and then we can close this issue. Cheers.

reharik commented 9 years ago

hey, so I guess while I have you, can you answer this for me? If I want to test that an exception is thrown when bad parameters are passed to a function, how would i do that? I just tried ( using the beta, thanks for that ) and my test passes when I expect it to pass. yay! but also passes when I expect it to fail. boo! I'm basically doing this moduleUnderTest.getById(val1, val2, val3).must.reject.to.equal(Error); I'm testing that val3 is a pos int. but it passes whether I pass 6 or -6. Any ideas? thanks, R

On Mon, Jun 15, 2015 at 3:14 PM, Andri Möll notifications@github.com wrote:

Aand done! ;-) Published all of the current changes as v0.13.0-beta1. You should be able to get it by using npm install must@beta.

Let me know if that works and then we can close this issue. Cheers.

— Reply to this email directly or view it on GitHub https://github.com/moll/js-must/issues/30#issuecomment-112194426.

reharik commented 9 years ago

Yes I must be missing something (no pun intended) I just put must.resolve.to.equal(400) which of course is not what I would be getting back and it should have thrown an error before returning anyway, and the test passed. I can provide a bit more if you need it. thanks, r

On Mon, Jun 15, 2015 at 3:19 PM, Raif Harik reharik@gmail.com wrote:

hey, so I guess while I have you, can you answer this for me? If I want to test that an exception is thrown when bad parameters are passed to a function, how would i do that? I just tried ( using the beta, thanks for that ) and my test passes when I expect it to pass. yay! but also passes when I expect it to fail. boo! I'm basically doing this moduleUnderTest.getById(val1, val2, val3).must.reject.to.equal(Error); I'm testing that val3 is a pos int. but it passes whether I pass 6 or -6. Any ideas? thanks, R

On Mon, Jun 15, 2015 at 3:14 PM, Andri Möll notifications@github.com wrote:

Aand done! ;-) Published all of the current changes as v0.13.0-beta1. You should be able to get it by using npm install must@beta.

Let me know if that works and then we can close this issue. Cheers.

— Reply to this email directly or view it on GitHub https://github.com/moll/js-must/issues/30#issuecomment-112194426.

moll commented 9 years ago

Does moduleUnderTest.getById(val1, val2, val3) return a promise which should fail? What does the error it rejects with look like and what do you want to assert on it? You might want to list the full test case and using GitHub's markdown gets us syntax highlighting here too. ;-)

I'll close this issue for now as the publishing wish seems resolved. :-)

reharik commented 9 years ago

yes, method returns a promise that resolves to "new Error("version number must be greater than or equal to 0")" It's a bit unorthodox as I'm using async/await with babel, but basically you put a try catch around your code, then re-throw and that is returned as a promise.reject(your new thrown error). I have console.logged it and it is definitely returning a Promise and that promise has the correct message in it. I was seeing this with chai as well, which is what sent me out looking for something else. ok, so I cooked this up

it("should throw error", function() {
    var test = function(){
       return Promise.resolve(4);
    }
    test().must.reject.to.equal(new Error("error"));
});

I started with return Promise.reject(new Error("error)); both versions pass. sorry about the mark down, I don't really know the github version. we'll see how well the stackoverflow version works here. aslo I had to copy this by hand for reasons to bizzar and lengthy to go into so any typos are incidental. the code runs in my test harness. Thanks, R

On Mon, Jun 15, 2015 at 3:23 PM, Andri Möll notifications@github.com wrote:

Does moduleUnderTest.getById(val1, val2, val3) return a promise which should fail? What does the error it rejects with look like and what do you want to assert on it? You might want to list the full test case and using GitHub's markdown gets us syntax highlighting here too. ;-)

I'll close this issue for now as the publishing wish seems resolved. :-)

— Reply to this email directly or view it on GitHub https://github.com/moll/js-must/issues/30#issuecomment-112197730.

moll commented 9 years ago

Click the "Markdown supported" button in the text field here to see a manual for Markdown. ;-)

Are you using Mocha? You need to return the promise for Mocha to wait until it's resolved. Prefix test() with return. Otherwise it'll be a silent failure. ;-)

You might want to see Must.js's API docs and use the error matcher. Equal is the same as === and those two error instances are always different. ;)

moll commented 9 years ago

I think those API docs show a complete example. Try that and see if that works. Then, start substituting your code bit by bit to see where it fails.

reharik commented 9 years ago

ok, so yea, typing return does seem to do wonders. so in my proper test should I do

return mut.getById(badAgg,'','').must.reject.to.equal('aggregateType must inherit from AggregateBase');

or do I need to return var promise then assert? r

On Mon, Jun 15, 2015 at 3:46 PM, Andri Möll notifications@github.com wrote:

Click the "Markdown supported" button in the text field here to see a manual for Markdown. ;-) Are you using Mocha? You need to return the promise for Mocha to wait until it's resolved. Prefix test() with return. Otherwise it'll be a silent failure. ;-)

You might want to see Must.js's API docs and use the error matcher. Equal is the same as === and those two error instances are always different. ;)

— Reply to this email directly or view it on GitHub https://github.com/moll/js-must/issues/30#issuecomment-112206030.

moll commented 9 years ago

If you return before asserting, you'll never run the assert. ;) So you're doing it right. Using the asyncand await thing might make things simpler though as you then don't have to return promises.

reharik commented 9 years ago

great. thanks for you help and sorry to take up your time. I have one last quick one. maybe two. my promise is rejecting with an Error. is there anyway to test the message on the error? or do I need to recreate the entire error and do an to.equal( ) on it? also are you suggesting I use async/await in my test? I am using it in my code and that i what is returning the promise. Thanks again

On Mon, Jun 15, 2015 at 3:58 PM, Andri Möll notifications@github.com wrote:

If you return before asserting, you'll never run the assert. ;) So you're doing it right. Using the asyncand await thing might make things simpler though as you then don't have to return promises.

— Reply to this email directly or view it on GitHub https://github.com/moll/js-must/issues/30#issuecomment-112209786.

reharik commented 9 years ago

Ok before I head out just wanted to summarize my findings. a) if you return a promise that is supposed to return an error with a certain message

so, having resolved my issues, I would like to say that i like your library much better than chai ( although it's hard to stop typing should as I"ve been doing it for decade in c# ). Thank you, R

On Mon, Jun 15, 2015 at 4:02 PM, Raif Harik reharik@gmail.com wrote:

great. thanks for you help and sorry to take up your time. I have one last quick one. maybe two. my promise is rejecting with an Error. is there anyway to test the message on the error? or do I need to recreate the entire error and do an to.equal( ) on it? also are you suggesting I use async/await in my test? I am using it in my code and that i what is returning the promise. Thanks again

On Mon, Jun 15, 2015 at 3:58 PM, Andri Möll notifications@github.com wrote:

If you return before asserting, you'll never run the assert. ;) So you're doing it right. Using the asyncand await thing might make things simpler though as you then don't have to return promises.

— Reply to this email directly or view it on GitHub https://github.com/moll/js-must/issues/30#issuecomment-112209786.