Javascript 为每个测试清除cookies不工作。使用业力+奎尼特(使用巴甫洛夫)+余烬。在PhantomJS/Chrome中运行
我需要在每次测试之前清除登录cookie,因为以前的测试可能已经存储了cookie。这就是我现在所拥有的,但它似乎并没有消除cookie/凭证,因为在上述删除之后,客户端的请求仍然得到200。任何帮助都将不胜感激Javascript 为每个测试清除cookies不工作。使用业力+奎尼特(使用巴甫洛夫)+余烬。在PhantomJS/Chrome中运行,javascript,cookies,ember.js,qunit,karma-runner,Javascript,Cookies,Ember.js,Qunit,Karma Runner,我需要在每次测试之前清除登录cookie,因为以前的测试可能已经存储了cookie。这就是我现在所拥有的,但它似乎并没有消除cookie/凭证,因为在上述删除之后,客户端的请求仍然得到200。任何帮助都将不胜感激 var clearCookies = function() { var cookiesToDelete = ["cookie1", "cookie2"] cookiesToDelete.forEach(function(cookie) {
var clearCookies = function() {
var cookiesToDelete = ["cookie1", "cookie2"]
cookiesToDelete.forEach(function(cookie) {
document.cookie = cookie + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=.domain.com";
})
测试:
Ajax在assert语句中调用,删除cookie后仍然获得200
$.ajax({
url: clientUrl,
dataType: "json",
xhrFields: {
withCredentials: true
},
success: function() {},
error: function() {}
})
我最终做的工作是调用注销API,而不是清除cookies
describe("CRITERIA 1:", function () {
before(function () {
logout() // logout instead of clearing cookies
App.reset()
visit('/')
})
it(function() {
//asserts in here seem to still use cookie!
})
})
describe("CRITERIA 1:", function () {
before(function () {
logout() // logout instead of clearing cookies
App.reset()
visit('/')
})
it(function() {
//asserts in here seem to still use cookie!
})
})