4

tests/acceptance/index-test.js在 ember-cli 版本 0.0.22 应用程序中有以下内容:

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)

看来我在加载代码时遇到了问题。项目中的占位符文件会很有用。我怎样才能让它工作?

4

2 回答 2

9

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

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

test('index transitions', function(){
  startApp();
  visit('/');
  andThen(function(){
    equal(find('h3.breadcrumb').text(), 'Title');
  });
});
于 2014-04-11T15:39:32.087 回答
4

将此部分添加到 ember-cli 的文档中。

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

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

...而不是在每个test.

于 2014-07-11T00:58:28.910 回答