expect(object).toEqual(object)抛出错误对象读取没有方法调用

时间:2015-05-18 05:35:24

标签: javascript jasmine jasmine-jquery

我一直在尝试比较茉莉花中的两个javascript对象。但我收到错误对象读取没有方法调用。

describe("AutoEditor", function() {

  var widgetList = ["widget1","widget2"];
  var oldEdgeStructure = {};
  oldEdgeStructure.SingleLink = [{"widget1":[{"EdgePosition":"s","WidgetID":"widget2"}]},
    {"widget2":[{"EdgePosition":"n","WidgetID":"widget1"}]}];

  it("read edges", function(done) {

    require(['auto-editor'], function(EdgeStructures) {
        var containerEl = $('#container');
        var edgeStructures = EdgeStructures.readEdges(widgetList,containerEl);
        expect(edgeStructures.SingleLink).toEqual(oldEdgeStructure.SingleLink);
        done();
    });

  });

});

1 个答案:

答案 0 :(得分:0)

收到错误是因为在将div附加到DOM之后我没有在正文中加载Edgestructures。米哈尔你是对的。在加载DOM内容并解决问题后,我刚刚添加了脚本标记,我在body标签中加载了我的库。