我正在尝试为实习生功能测试设置 cookie,但页面上似乎没有 cookie 数据。这是设置:
registerSuite(function() {
'test': function() {
return this.remote
.get(require.toUrl("index.html")
.setFindTimeout(5000)
.setCookie({name: "foo", value: "bar"})
.then(function() {
//... test here ...
});
}
});
访问 index.html 中的 document.cookie 时,没有数据。关于我做错了什么的任何提示?
更新:
我还没有解决问题,但发现您需要在 get() 之前调用 setCookie()。我解决这个问题的方法是在 noop URL 上调用 get(),然后调用 setCookie()
return this.remote
.get('/')
.setCookie({name: "foo", value: "bar"})
.get(require.toUrl("index.html")
.setFindTimeout(5000)
.setCookie({name: "foo", value: "bar"})
.then(function() {
//... test here ...
});