@smartesting/assert-contain-exactly
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

@smartesting/assert-contain-exactly

Node.js CI

Simple test helper ensuring a list contains exactly the expected elements, without taking care of order. It is strongly inspired by Rspec's contain_exactly matcher.

Install

npm i --save-dev @smartesting/assert-contain-exactly

Usage

import assertContainExactly from "@smartesting/assert-contain-exactly";

const expected = ["a", "b", "c"];
const actual = getItems();
assertContainExactly(actual, expected);

When the arrays actual and expected, nothing happens. Otherwise, an exception is thrown and the message should help you spot the differences between the two arrays:

Error: Expected arrays to contain the same objects.
Missing elements were: [
  {
    id: "session-2",
    buildId: "13"
  }
]
Extra elements were: [
  {
    id: "session-B",
    buildId: "13"
  }
]
    at assertIncludesExactly (...)

Notes

This code is meant to be used for testing purposes. The algorithm is not that smart not designed to handle arrays with hundred of items.

Readme

Keywords

Package Sidebar

Install

npm i @smartesting/assert-contain-exactly

Weekly Downloads

73

Version

0.1.4

License

MIT

Unpacked Size

6.12 kB

Total Files

10

Last publish

Collaborators

  • jracenet
  • admin-smartesting
  • smart-rfe
  • c.grandpierre
  • vincentpsmartesting
  • yakaldir
  • aymerictn