1
votes

I want to premise that I'm aware of Ember QUnit (recently covered at EmberConf) as well as using PhantomJS so please read my points in question closely if you're thinking of marking as a duplicate.

My goal is to run unit tests from the command line, similar to a mocha test might run

mocha simple_test.js

and see the results in the form of a command line reporter.

  1. testing ember modules in isolation. I would like to be able to new-up an ember object, route, or controller without the context of a running ember app (perhaps some kind of ember test harness) and run assertions against that module.
  2. testing ember modules in the command line (avoiding browser reporters like QUnit or headless browsers like PhantomJS)

I already have integration and acceptance tests using a combination of karma and phantomjs, I would like to see if I can compliment with more unit tests. Has anybody come across a unit test setup similar to to what I listed above or is it not really possible and/or productive?

Update The ember guides list unit testing strategies here: http://emberjs.com/guides/testing/unit/

In my opinion, these seem more like integration tests.

1

1 Answers

2
votes

Yeah I do this with my application. You might like to look at the new testing guides in the ember site's documenation if you haven't already seen it (it went live last week sometime). I helped edit it. It's pretty good! :-)

Good luck and let me know if you need any more help, like I say, I do unit tests all the time on all parts of Ember. The hardest so far for me has been components because they're neither integration nor unit, really... they're like a hybrid: isolated integration unit tests that still require large parts of ember and rendering in the view.

I run headless using guard, jasmine and qunit. Jasmine's my preference and I've been moving over from qunit slowly.

http://emberjs.com/guides/testing/

Also I noticed that what you seem to want is to isolate the units outside of even ember itself. To do that, I'd put your code in separate javascript libraries... otherwise you'll have troubles: afterall how are you going to unit test a piece of code without Ember present if it uses Ember?