New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

expect-more-jest

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expect-more-jest

Write Beautiful Specs with Custom Matchers

  • 2.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28K
decreased by-0.13%
Maintainers
1
Weekly downloads
 
Created
Source

expect-more-jest

Write Beautiful Specs with Custom Matchers for Jest

NPM version NPM downloads Build Status Code Climate Gitter Chat for expect-more Donate via PayPal Analytics Follow JamieMason on GitHub Follow fold_left on Twitter

expect-more-jest is a huge library of test matchers for a range of common use-cases, to make tests easier to read and produce relevant and useful messages when they fail. Avoid vague messages such as "expected false to be true" in favour of useful cues like "expected 3 to be even number", and avoid implementation noise such as expect(paws.length % 2 === 0).toEqual(true) in favour of simply stating that you expect(paws.length).toBeEvenNumber().

Installation

npm install expect-more-jest --save-dev

Configuration

The simplest way to integrate is to set the setupTestFrameworkScriptFile value of Jest's jest.config.js to require.resolve('expect-more-jest'). If your project requires more setup than just registering these matchers, include require('expect-more-jest'); or import 'expect-more-jest'; somewhere in the file you have pointed your setupTestFrameworkScriptFile at.

Note: If your Editor does not recognise that you are using custom matchers, add a global.d.ts file at the root of your project containing:

import 'expect-more-jest';

Matchers

expect(date: Date).toBeAfter(other: Date)
expect(value).toBeArray()
expect(value).toBeArrayOfBooleans()
expect(value).toBeArrayOfNumbers()
expect(value).toBeArrayOfObjects()
expect(value).toBeArrayOfSize(size: number)
expect(value).toBeArrayOfStrings()
expect(date: Date).toBeBefore(other: Date)
expect(value).toBeBoolean()
expect(value).toBeCalculable()
expect(value).toBeDate()
expect(value).toBeDivisibleBy(other: number)
expect(value).toBeEmptyArray()
expect(value).toBeEmptyObject()
expect(value).toBeEmptyString()
expect(value).toBeEvenNumber()
expect(value).toBeFalse()
expect(value).toBeFunction()
expect(value).toBeIso8601()
expect(value).toBeJsonString()
expect(value: string | any[]).toBeLongerThan(other: string | any[])
expect(value).toBeNonEmptyArray()
expect(value).toBeNonEmptyObject()
expect(value).toBeNonEmptyString()
expect(value).toBeNumber()
expect(value).toBeObject()
expect(value).toBeOddNumber()
expect(value).toBeRegExp()
expect(value: string | any[]).toBeSameLengthAs(other: string | any[])
expect(value: string | any[]).toBeShorterThan(other: string | any[])
expect(value).toBeString()
expect(value).toBeTrue()
expect(value).toBeValidDate()
expect(value).toBeWhitespace()
expect(value).toBeWholeNumber()
expect(value: string).toEndWith(other: string)
expect(fn).toHandleMissingBranches(shape: object | any[])
expect(fn).toHandleMissingLeaves(shape: object | any[])
expect(fn).toHandleMissingNodes(shape: object | any[])
expect(fn).toHandleNullBranches(shape: object | any[])
expect(fn).toHandleNullLeaves(shape: object | any[])
expect(fn).toHandleNullNodes(shape: object | any[])
expect(value: string).toStartWith(other: string)

FAQs

Package last updated on 26 Aug 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