Search code examples
ember.jsember-clitestem

Ember cli and testem


I'm new to Ember, and I'd like to get a simple project up and running, and have some integration tests running in chrome.

I bought the book "Developing an Ember.js Edge" where they create the application ember-trackr but as all things in the JS world move fast, details seem to have changed.

If I:

git clone https://github.com/developing-an-emberjs-edge/ember-trackr
cd ember-trackr
testem

I get an error:

   Error running before_tests hook                                         
  ┃                                                                        
  ┃before_tests hook: "ember build -c"                                     
  ┃version: 0.0.41                                                         
  ┃You have to be inside an ember-cli project in order to use the build command.

I'm not sure but I think the steps in http://emberjs.com/guides/testing/integration/ are already taken care of when using

ember new <appname>

So, if I create a new app and run testem:

ember new testem-test
cd testem-test
testem

I see the 'waiting for runners' message in the console and chrome launces.

Now if I try to add a trivial test (say, to check the page content for some text - copied from http://www.ember-cli.com/#testing) as tests/test1.js:

 import Ember from "ember";
 import { test } from 'ember-qunit';
 import startApp from 'helpers/start-app';
 var App;

 module('An Integration test', {
   setup: function() {
     App = startApp();
   },
   teardown: function() {
     Ember.run(App, App.destroy);
   }
 });

 test("Page contents", function() {
   expect(2);
   visit('/foos').then(function() {
     equal(find('.foos-list').length, 1, "Page contains list of models");
     equal(find('.foos-list .foo-item').length, 5, "List contains expected number of models");
   });
 });

If I run 'testem', I just get the waiting for runners message.

If I run 'ember test' I get:

~/IdeaProjects/spike/testem-test (master) $ ember test
version: 0.0.41
Build failed.
ENOENT, no such file or directory '/Users/paul/IdeaProjects/spike/testem-test/tmp/tree_merger-tmp_dest_dir-2QJNmsEl.tmp/helpers/start-app.js'
File: helpers/start-app.js

Does anyone have any clues as to what I'm missing?

Also, if it hasn't been done already, it would be nice to keep the ember-trackr sample app up to date with ember-cli so it runs out of the box - I'd be happy to contribute if I can figure out what its missing...

Thanks.


Solution

  • For the first part of your problem, yes ember-cli has changed, and you have to migrate that project. I would do that for 100 bounty.

    For the second part, you don't have to create a test from scratch:

    run ember generate acceptance-test test1 and it will do the boilerplate for you.

    the specific error message can be fixed by updating this line:

    import startApp from '../helpers/start-app';