• used to perform a comparisons between two objects or arrays where the actual is a super-set of the expected. for example:

    const expected = {
    foo: 'bar',
    baz: true
    }
    const actual = {
    foo: 'bar',
    baz: true,
    meaning: 42
    }
    const res1 = equivalent(expected)
    .setActual(actual)
    .compare(); // returns `true`
    const res2 = equivalent(actual)
    .setActual(expected)
    .compare(); // returns `false`
    console.log(res2.failureString()); // 'actual.meaning' unset while 'expected.meaning' had a value

    usage within a AftTest.verify function would look like:

    const t = new AftTest('description', () => null);
    await t.verify(() => actualObject, equivalent(expectedObj, 6)); // succeeds if `actualObject` has matching properties and values to `expectedObject`

    Parameters

    • expected: Record<string | number | symbol, any>

      the expected value

    • maxDepth: number = Infinity

      the maximum level to recurse into any object properties

    Returns EquivalentTo

    a new EquivalentTo instance

    Default

    Infinity
    

Generated using TypeDoc