Skip to content

Notes on testing w Ember

Andrewmp1 edited this page Mar 20, 2013 · 3 revisions

testing your app in a browser?

Conflict between your app and potentially the test runner generated html

  • some workarounds include using frames

Application state between tests

Ember specific gotchas

  • Separating your app from the server
  • Neuter any ajax calls
  • User Ember.testing = true when you need to control the run loop. NOTE: Can you still boot your app?
  • User Application.reset() NOTE: "This does not seem to be available. Is it on .container.reset()"

Simulating user input in the browser w/ ember apps

  • Cannot use $.val() to fill in user input as no event is sent to ember to tell it that the element has changed
  • Call change event on element to tell Ember it has changed. el.trigger('change')

http://code418.com/blog/2012/03/08/useful-emberjs-functions/ Useful Ember functions:

  • isEqual Ember.isEqual('1', '2') Check if logically equal.
  • typeof Ember.typeOf(); // 'undefined' Ember.typeOf(null); // 'null' Ember.typeOf(undefined); // 'undefined' Ember.typeOf('michael'); // 'string' Ember.typeOf(101); // 'number' Ember.typeOf(true); // 'boolean' Ember.typeOf(Ember.makeArray); // 'function' Ember.typeOf([1,2,90]); // 'array' Ember.typeOf(Ember.Object.extend()); // 'class' Ember.typeOf(Ember.Object.create()); // 'instance' Ember.typeOf(new Error('teamocil')); // 'error' // "normal" JavaScript object Ember.typeOf({a: 'b'}); // 'object'
  • compare() Ember.compare('hello', 'hello')
  • inspect() Ember.inspect()

More General information on testing:

Great javascript jabber talk on QUNIT/JS Testing in general: http://javascriptjabber.com/050-jsj-qunit-with-jorn-zaefferer/

Clone this wiki locally