3
votes

This page, ember-cli testing, says "The included tests demonstrate how to write both unit tests and acceptance/integration tests using the new ember-testing package."

However in order to get an integration test working, I need to find module and visit or any of the ember test helpers. Where are they found, where can I import them from?


Details:

The closest I have found to module is moduleFor, which can be imported from ember-qunit. Module for is not suitable for integration testing as I am testing an entire page or series of pages within the app, rather than an individual model, route, controller, view, etc.

My best guess is that visit can be found within Ember itself, but I am not sure where to import it from.

Using neither module nor moduleFor, I am able to run the tests, but they error out:

ReferenceError: visit is not defined

2

2 Answers

9
votes

ember-cli generates start-app.js file which includes function that prepare ember for testing.

in your integration test file...

import startApp from '../../helpers/start-app'; // change this due to your folder hierarchy

var App;

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

now your Ember App is ready for testing. You can use ember-testing helpers.

1
votes

Extending @saygun`s answer. As of now instead of module we will be using moduleForComponent or moduleFor as needed. Eg:

moduleForComponent('comp-name', 'Integration | Component | comp name', {
  integration: true,
  setup: function(){
    App = startApp();
  },
  teardown: function(){
    Ember.run(App, 'destroy');
  }
});