Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chai-expected-cookie

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-expected-cookie

Chai plugin for testing HTTP response set-cookie header and it's also support supertest.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Chai plugin for testing HTTP response set-cookie header and it's also support supertest.

Installation

npm install chai-expected-cookie

Usage

Quick example

const chai = require('chai');
const expect = chai.expect;
chai.use(require('chai-http'));
chai.use(require('chai-expected-cookie'));

response = ...

expect(response).to.containCookie({
    name: 'key_1',
});

expect(response).to.not.containCookie({
    name: 'key_2',
});

expect(response).to.containCookie({
    name: 'key_3',
    value: 'vk_3'
});

expect(response).to.containCookie({
    name: 'key_4',
    attrs: {
        path: '/path'
    }
});

expect(response).to.containCookie({
    name: 'key_5',
    hasAttrs: [
        'httponly'
    ]
});

expected(response).to.containCookie({
    name: 'key_6',
    value: 'vk_6',
    attrs: {
        path: '/path'
    },
    hasAttrs: [
        'httponly'
    ]
});

Complete example

const chai = require('chai');
const expect = chai.expect;
chai.use(require('chai-http'));
chai.use(require('chai-expected-cookie'));

const express = require('express');
const app = express();

chai.request(app)
    .get('/items')
    .end(function(err, response) {         
        expect(response).to.containCookie({
            name: 'key_1',
        });

        expect(response).to.not.containCookie({
            name: 'key_2',
        });

        expect(response).to.containCookie({
            name: 'key_3',
            value: 'vk_3'
        });

        expect(response).to.containCookie({
            name: 'key_4',
            attrs: {
                path: '/path'
            }
        });

        expect(response).to.containCookie({
            name: 'key_5',
            hasAttrs: [
                'httponly'
            ]
        });

        expected(response).to.containCookie({
            name: 'key_6',
            value: 'vk_6',
            attrs: {
                path: '/path'
            },
            hasAttrs: [
                'httponly'
            ]
        });
    });

API

containCookie(expectedCookie)

assert cookies with defined criteria is set.

Arguments

  • expectedCookie - object represent expected cookie criteria
    • name - cookie name
    • value - Optional cookie value
    • attrs - Optional object cookie of attributes
    • hasAttrs - Optional array of cookie attribute names

License

MIT

Keywords

FAQs

Package last updated on 01 Jan 2018

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc