supertest
supertest copied to clipboard
Add cookie assertions framework
Add a convenient workflow for running assertions on cookie headers returned by the server. This code is largely copied from Gregory Langlais' package expect-cookies (MIT License).
Implements #855.
Example usage:
const request = require('supertest');
const cookies = request.cookies;
request(app)
 .get('/users')
 .expect('Content-Type', /json/)
 .expect('Content-Length', '15')
 .expect(200)
 // assert 'alpha' cookie is set with domain, path, and httpOnly options
 .expect(cookies.set({ name: 'alpha', options: ['domain', 'path', 'httponly'] }))
 // assert 'bravo' cookie is NOT set
 .expect(cookies.not('set', { name: 'bravo' }))
 .end(function(err, res) {
   if (err) {
     throw err;
   }
 });
Supports:
.set- Assert that cookie and options are set..reset- Assert that cookie is set and was already set (in request headers)..new- Assert that cookie is set and was NOT already set (NOT in request headers)..renew- Assert that cookie is set with a strictly greaterexpiresormax-agethan the given value..contain- Assert that cookie is set with value and contains options..not- Call any cookies assertion method with "assert true" modifier set tofalse.
Checklist
- [x] I have ensured my pull request is not behind the main or master branch of the original repository.
- [x] I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
- [x] I have written a commit message that passes commitlint linting.
- [x] I have ensured that my code changes pass linting tests.
- [x] I have ensured that my code changes pass unit tests.
- [x] I have described my pull request and the reasons for code changes along with context if necessary.
Can you fix the merge conflict?
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
| Diff | Package | Supply Chain Security |
Vulnerability | Quality | Maintenance | License |
|---|---|---|---|---|---|---|
| cookie-signature@​1.2.2 | ||||||
| sinon@​20.0.0 |
Fixed. Sorry, not sure how that happened.
Everything look ok now?