Socket
Book a DemoInstallSign in
Socket

mock-session

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-session

Create required session object for testing, which is used with cookie-session.

latest
Source
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

mock-session

Create required session object for testing, which is used with cookie-session.

If you are using mocha + express + cookie-session and you need to set desired session object in tests or somewhere than this packge can be helpful.

npm install mock-session

mockSession('Session name of cookie-session',    
            'first key of cookie-session',      
            'data you need to add in session'     
          );

Example

let mockSession = require('mock-session');
let cookie = mockSession('my-session', 'my-secret', {"count":1});   
.
.
.
await request(app).get('api/images/create')
        .set('cookie', [cookie])
        .expect(200);

Controller Side: You'll receive session object like this

exports.create = function(req, res) {         
  if(req.session.count == 1) { // true                      
    //do something                
    res.sendStatus(200);                    
  }
}

Keywords

cookie, mocha, test, express, crypto, cookie-session, Keygrip

FAQs

Package last updated on 14 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.