hughsk/smokestack

mocha example

yoshuawuyts opened this issue · 9 comments

Would be nice to have one since it's probably the most used test runner out there. Will add one in soon™.

👍 sounds good :)

@yoshuawuyts PR welcome

I was trying to put together a PR for this, but the mocha output is getting appended to script.js, which causes the browser to hang and never close (and the process doesn't exit). Is there something special I should be doing besides mocha test.js | smokestack?

@bclinkinbeard smokestack works the other way around, you pipe the JS in and it runs it in a browser.

In your example, you're piping the text output of running the tests in, and then the browser is trying to execute the result of executing the test text as JavaScript.

You need to do something like:

cat test.js | smokestack

test.js would load mocha and everything needed to run the tests.

One way to make it work is using browserify.

browserify test.js on its own simply spits out the built JS to the terminal.

So then you can browserify test.js | smokestack and it will take the browserify js output, pass it into smokestack which runs it in the browser and pipes any console output back to the terminal.

Ah, right. I played with it a little more, but using mocha programmatically is a little funky because some of the globals used/exposed by the CLI are not there. I thought this would be an easy win but I guess I was wrong. Looking forward to somebody who knows it better stepping up. :)

@bclinkinbeard yeah, mocha is pretty annoying to deal with. Still haven't had the chance to do this well, I too thought it'd be easier than it is. Maybe we just need to rewrite mocha, haha :P

Don't think I'll come around to doing this, have recently ditched mocha in favor of tape. If anyone else wants to pick it up feel free to do so!

Though I'm not sure it's worth it since mocha has its own browser instrumentation thing.

Closing because of lack in activity. PRs are still welcome though!