meta { name: directReadMethods type: http seq: 11 } get { url: {{localhost}}/ping body: none auth: inherit } script:pre-request { const jar = bru.cookies.jar() const host = bru.getEnvVar('localhost'); await jar.setCookies(host, [ { key: 'alpha', value: 'one', path: '/' }, { key: 'beta', value: 'two', path: '/' } ]); } tests { test("one() should return full cookie object by name", function() { const cookie = bru.cookies.one('alpha'); expect(cookie).to.have.property('key', 'alpha'); expect(cookie).to.have.property('value', 'one'); }); test("one() should return undefined for nonexistent cookie", function() { expect(bru.cookies.one('nonexistent')).to.be.undefined; }); test("all() should return an array with at least 2 items", function() { const cookies = bru.cookies.all(); expect(cookies).to.be.an('array'); expect(cookies.length).to.be.at.least(2); }); test("count() should be at least 2", function() { expect(bru.cookies.count()).to.be.at.least(2); }); test("idx() should return a cookie object at index 0", function() { const cookie = bru.cookies.idx(0); expect(cookie).to.have.property('key'); expect(cookie).to.have.property('value'); }); test("toObject() should return object with cookie key-value pairs", function() { const obj = bru.cookies.toObject(); expect(obj).to.be.an('object'); expect(obj).to.have.property('alpha', 'one'); expect(obj).to.have.property('beta', 'two'); }); test("toString() should return a string containing cookie pairs", function() { const str = bru.cookies.toString(); expect(str).to.be.a('string'); expect(str).to.contain('alpha=one'); }); test("toJSON() should return cloned array of all cookies", function() { const json = bru.cookies.toJSON(); expect(json).to.be.an('array'); expect(json.length).to.be.at.least(2); expect(json[0]).to.have.property('key'); expect(json[0]).to.have.property('value'); }); const jar = bru.cookies.jar() await jar.clear() } settings { encodeUrl: true }