Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blue-tape vs. mocha #37

Closed
kaievns opened this issue Apr 18, 2016 · 6 comments
Closed

blue-tape vs. mocha #37

kaievns opened this issue Apr 18, 2016 · 6 comments

Comments

@kaievns
Copy link
Contributor

kaievns commented Apr 18, 2016

I've noticed that you use blue-tape as the default testing framework. why not mocha? it's a more widely used solution by a huge margin with a wastly more options for extensions. and it supports promises out of the box too. not to say that it also supports immensely useful things like global before/after hooks and spits out better BDD specs

@nwinch
Copy link
Contributor

nwinch commented Apr 18, 2016

From #32:

We could, though, look at the number of things that depend on Tape vs the things that depend on Mocha and decide whether the gulf is so vast that it's an obvious choice.

@davidbanham Do you mean "things" internally? Or we talking community wide?

I think we should roll with Mocha as we never had any problems with it as far as I know? It felt like Tape came out swinging and we used it on a couple of projects, but pretty quickly went back to using Mocha for a variety of reasons. I don't think Tape is bad, it was kinda cool to use on a couple of projects - it's really minimal, that's cool - but it did seem like the internet was arguing about Mochas global vars/functions etc.. when I don't remember them being a problem?

Another discussion that kinda gets lost in this, is using fluent assertions. I love em. Yeah assert does the job, but it's more taxing to read down a page and find what's being asserted - you've gotta read through each line of code to get the context you need to understand why assert(obj1 == result). Easier understood as obj.must.be.true().

@davidbanham
Copy link
Contributor

I'm talking community wide.

The Problem With Mocha that caused me to go to Tape in the first place is how much of a sackpain it is to compose it with things like istanbul.

They both want to control the binary that runs things. With enough dicking around with gulp and/or command line flags you can make them play nicely with each other, but it takes some doing.

I shudder to think what would happen if you tried to make babel-node do it's thing in there too.

The crux is that control of the root level binary is a powerful tool, but it's a big hassle when multiple things demand to use it. Any time we can jettison a tool that wants it in favour of one that doesn't, we should take a good hard look.

That said, it seems to have transpired that the pain of Tape'ing is worse than the pain of smashing Mocha into Istanbul into Babel and picking through the wreckage.

Another discussion that kinda gets lost in this, is using fluent assertions. I love em. Yeah assert does the job, but it's more taxing to read down a page and find what's being asserted - you've gotta read through each line of code to get the context you need to understand why assert(obj1 == result). Easier understood as obj.must.be.true().

I find the exact opposite. I like that assert has a nice simple syntax that's unambiguous. In your example it would actually be assert(obj1) as equivalent to obj1.must.be.true()

Or potentially:

assert.deepEqual(obj1, result) and obj1.must.eq(result)

Either way, they both capture exactly the same amount of information in a single line, requiring the same amount of spelunking through the state of the rest of the function.

Assert, however, does it without monkeypatching the global prototype of All The Things. It's also part of stdlib, so it's one less (or in the case of must, 8 less, http://npm.anvaka.com/#/view/2d/must) vector by which we can be left-padded.

@kaievns
Copy link
Contributor Author

kaievns commented Apr 18, 2016

i think it's worth separating the test runner and assertions libs discussions. chaijs can give you any style you like. or you can bring your own. i find that's one of the strengths of mocha as it doesn't lock you in with a specific assertions library.

i personally like mocha because it provides me with a robust and standard BDD interface for tests. I know what to do with it and when I'm done, i'm 99% sure that the next dev will know what to do with it as well.

as for bundling mocha with istanbul, it might be confusing a bit, but it is solvable in 100% of cases, with babel or without. I do it all the time. Just ask and I'll give you a working solution.

@davidbanham
Copy link
Contributor

davidbanham commented Apr 18, 2016

I've done it before too, so I know it's possible. It's just such a pain in the neck. If there was another test framework that was equally productive that didn't demand a binary, I wanted to use it. I thought Tape might be that, but it turns out not to be. C'est la vie. Tape is dead. Long live Mocha.

@kaievns
Copy link
Contributor Author

kaievns commented Apr 18, 2016

i don't really see the pain tbh. it's just an one line in your "scripts" section.

besides we're building a generator, right? we solve it once here and then every time someone generates a new project it will be automatically setup for them :)

@nwinch
Copy link
Contributor

nwinch commented Apr 18, 2016

Bye Tape. I guess you just didn't stick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants