最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Setting up integration tests in an ember-cli app - how to access module() and visit()? - Stack Overflow

programmeradmin11浏览0评论

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

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

Share Improve this question edited Jun 4, 2014 at 6:12 bguiz asked Jun 3, 2014 at 8:32 bguizbguiz 28.4k49 gold badges163 silver badges253 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

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.

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

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

评论列表(0)

  1. 暂无评论