使用第三方(赃物)助手进行Ember测试

时间:2015-07-23 06:53:09

标签: ember.js integration-testing ember-cli

我正在尝试为Ember-cli组件编写集成测试,该组件使用swag助手(特别是is),但我无法弄清楚如何加载助手以便它们可用于测试。我的测试很简单,我只是尝试渲染组件:

import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';


moduleForComponent('search-box', 'Integration | Component | search box', {
  integration: true
});

test('it renders', function(assert) {
  assert.expect(1);

  this.render(hbs`{{search-box}}`);

  assert.equal(this.$().text().trim(), '');
});

但它失败了

 ok 42 PhantomJS 2.0 - Integration | Component | search box: it renders
    ---
        actual: >
            null
        message: >
            Died on test #1     at test (http://localhost:7357/assets/test-support.js:1808:15)
                at http://localhost:7357/assets/client.js:14772:19
                at http://localhost:7357/assets/vendor.js:150:34
                at tryFinally (http://localhost:7357/assets/vendor.js:30:21)
                at requireModule (http://localhost:7357/assets/vendor.js:148:15)
                at require (http://localhost:7357/assets/test-loader.js:29:16)
                at loadModules (http://localhost:7357/assets/test-loader.js:21:25)
                at load (http://localhost:7357/assets/test-loader.js:40:35)
                at http://localhost:7357/assets/test-support.js:5609:20: Assertion Failed: A helper named 'is' could not be found
        Log: >
    ...

我尝试使用start-appSwag.registerHelpers()帮助中注册赃物,但我仍然收到上述错误,并出现jshint错误:helpers/start-app.js: line 21, col 5, 'Swag' is not defined.

当我运行应用程序时,帮助程序会加载,所以如何为测试注册它们?

0 个答案:

没有答案