hughsk / smokestack

Pipe your JavaScript into a browser, logging console output in Node
Other
245 stars 26 forks source link

mocha example #11

Closed yoshuawuyts closed 9 years ago

yoshuawuyts commented 9 years ago

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

hughsk commented 9 years ago

:+1: sounds good :)

timoxley commented 9 years ago

@yoshuawuyts PR welcome

bclinkinbeard commented 9 years ago

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?

timoxley commented 9 years ago

@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.

bclinkinbeard commented 9 years ago

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. :)

yoshuawuyts commented 9 years ago

@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

yoshuawuyts commented 9 years ago

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!

yoshuawuyts commented 9 years ago

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

yoshuawuyts commented 9 years ago

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