我怎样才能进行验收测试?

时间:2014-04-11 01:34:12

标签: javascript ember.js ember-cli

我在ember-cli版本0.0.22 app中有以下tests/acceptance/index-test.js

import startApp from '../helpers/start-app';
test('index transitions', function(){
  visit('/');
});

当我去http://localhost:4200/tests时,我看到了:

Died on test #1
at eval (ember-cli/tests/acceptance/index-test.js:7:5)
at requireModule (loader/loader.js:54:29)
at eval (ember-cli/tests/test-loader.js:9:7)
at Array.forEach (native)
at eval (ember-cli/tests/test-loader.js:8:8)
at requireModule (loader/loader.js:54:29)
at http://localhost:4200/tests:43:7: visit is not defined

Source: ReferenceError: visit is not defined
at Object.eval (ember-cli/tests/acceptance/index-test.js:8:7)

我似乎无法加载代码。项目中的占位符文件很有用。我怎样才能使它发挥作用?

2 个答案:

答案 0 :(得分:9)

我需要在测试文件中调用startApp();,例如:

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

test('index transitions', function(){
  startApp();
  visit('/');
  andThen(function(){
    equal(find('h3.breadcrumb').text(), 'Title');
  });
});

答案 1 :(得分:4)

我将this section添加到ember-cli的文档中。

请务必在模块的startApp()中调用setup,如下所示:

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

...而不是在每个test内。

相关问题