Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember CLI Test Helpers

Can somebody point me to a resource on how to implement a test helper with ember-cli?

Or else a simple explanation?

I know the helpers go in the test/helpers directory, but how do you load them into the integration tests?

Thanks

like image 406
l33z3r Avatar asked Sep 09 '14 19:09

l33z3r


1 Answers

The only way I found to do this is:

// tests/helpers/controller.js
import Ember from 'ember';

Ember.Test.registerHelper('controller', function (app, name) {
  return app.__container__.lookup('controller:' + name);
});

then in my acceptance test:

// acceptance/index-test.js
import Ember from 'ember';
// import our helper (this might be done within helpers/start-app.js to always import all helpers)
import '../helpers/controller';
import startApp from '../helpers/start-app';

// your tests using the helper(s)

But there might be some better way of doing.

like image 154
Huafu Avatar answered Sep 22 '22 09:09

Huafu