我试图用javascript茉莉花为此功能编写一个茉莉花测试,然后遇到此错误。
window.mainFun = function(){
doSomething();
}
function doSomething(){
var a=["aa","ac","aa","ab","aa","ad","aa"];
var c={};
var b = new Set(groupTokens);
var i=0
b.forEach(function (item) {
c["a"+(i++)] = item;
}
return c;
}
然后我收到此错误:TypeeError: undefined is not a constructor (evaluating setVariable.forEach)
我试图这样测试此代码:
describe("test suite", function() {
it("test spec", function() {
window.mainFun();
expect(window.doSomething()).toEqual("{aa,ab,ac,ad}");
});
});
但是我遇到了同样的错误。