0.1.4 • Published 3 years ago
@smartesting/assert-contain-exactly v0.1.4
@smartesting/assert-contain-exactly
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-exactlyUsage
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.