使用Jasmine测试Twitter Flight Component

时间:2016-04-13 15:17:40

标签: jasmine karma-jasmine jasmine-jquery twitter-flight

使用Twitter Flight运行Jasmine Test时出现问题。我正在使用jasmine-flight插件。

错误(S)

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
TypeError: this.Component is not a constructor
    at Object.setupComponent (/frontend/bower_components/jasmine-flight/lib/jasmine-flight.js:44:23)
    at Object.<anonymous> (/frontend/test/spec/component_ui/list-spec.js:5:10)
TypeError: Cannot read property 'trigger' of null
    at Object.<anonymous> (/frontend/test/spec/component_ui/list-spec.js:19:19)

测试组件

    describeComponent('javascript/component_ui/list-ui', function() {
      'use strict';
  beforeEach(function() {
    jasmine.getFixtures().fixturesPath = 'base/test/fixtures';
    this.setupComponent(
        readFixtures('list.html'),
        {
          listRightMenu: '.list-right',
          listSortSelector: '.list-sort',
        }
      );
  });

      it('Show menu when button is clicked', function() {

        console.log(this);

        this.component.trigger(this.component.attr.listSortSelector, 'click');
        expect(this.component.attr.listRightMenu).toBeVisible();
      });
    });

0 个答案:

没有答案