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

jest-expect-jwt

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-expect-jwt

A nicer way to compare JWT properties in tests

  • 0.0.1
  • npm
  • Socket score

Version published
Weekly downloads
160
decreased by-56.87%
Maintainers
1
Weekly downloads
 
Created
Source

jest-expect-jwt

A nicer way to compare JWT properties in tests

Expectations

toBeTokenContaining

It can be used to compare the object encoded within the token excluding the iat.

Example:

expect(token).toBeTokenContaining({ hello: "world" });

toBeTokenExpiringIn

Check when the token is expiring. This gives a couple of seconds leway either side to avoid having to mock dates. The expiry time can be written in a human readable format by using zeit/ms

Example:

expect(token).toBeExpiringIn("24h");

Setup

1. Install the package

npm

npm install --save-dev jest-expect-jwt

yarn

yarn add --dev jest-expect-jwt

2. Configure it within jest

Add it your jest config either jest.config.js or package.json.

{
  ...
  "setupFilesAfterEnv": ["jest-expect-jwt"],
  ...
}

FAQs

Package last updated on 01 Nov 2019

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