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

expect-predicate

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

expect-predicate

An extension for expect that lets you test values against arbitrary predicates

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

expect-predicate


NPM Version NPM Downloads Build Status devDependency Status

expect-predicate is an extension for expect that lets you test values against arbitrary predicates.

A value "passes" a predicate if the predicate returns a truthy value.


Installation

Using npm:

  $ npm install --save-dev expect expect-predicate

Then, use as you would anything else:

// using ES6 modules
import expect from 'expect'
import expectPredicate from 'expect-predicate'
expect.extend(expectPredicate)

// using CommonJS modules
var expect = require('expect')
var expectPredicate = require('expect-predicate')
expect.extend(expectPredicate)

Assertions

toPass

expect(value).toPass(predicate, [message])

Asserts the given value passes the given predicate. If you provide a message, it will be used when reporting the failure.

expect(age).toPass(n => n >= 18)                // check age is 18 or older
expect(userList).toPass(array => array.length)  // check that userList is not empty

toNotPass

expect(value).toNotPass(predicate, [message])

Asserts the given value does NOT pass the given predicate. If you provide a message, it will be used when reporting the failure.

expect(age).toNotPass(n => n < 18)                 // check age is not under 18
expect(userList).toNotPass(array => array.length)  // check that userList is empty

Keywords

FAQs

Package last updated on 29 Apr 2016

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