Socket
Book a DemoInstallSign in
Socket

deep-assert

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-assert

Better deep-equals object expectations, supporting dynamic bottom-up assertions using any() and satisfies().

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
138
94.37%
Maintainers
1
Weekly downloads
 
Created
Source

deep-assert

Build Status npm

Providing a better deep-equals assertion experience.

  • Easily write object and array expectations, with any() and satisfies()
  • Create your own custom assertions
  • Short, but precise diffs, even for large nested objects
  • Works with objects, arrays, dates, buffers, etc
  • Zero dependencies

Terminal

Installation

npm install deep-assert

Usage

Basic

import * as assert from "assert-deep"

assert.deepEquals(getUsers() , [
  {
    id: assert.any(),
    name: "John Smith",
    active: true
  },
  {
    id: assert.any(),
    name: "Jane Smith",
    active: false
  }
])

Custom assertions

import * as assert from "assert-deep"

const uuidRegex = /^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$/
const assertUUID = assert.satisfies(value => typeof value === "string" && value.match(uuidRegex))

assert.deepEquals(getUsers() , [
  {
    id: assertUUID(),
    name: "John Smith",
    active: true
  },
  {
    id: assertUUID(),
    name: "Jane Smith",
    active: false
  }
])

License

MIT

Keywords

assert

FAQs

Package last updated on 27 Apr 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