• compares the passed in actual has each of the expected property names and optionally also if the specified property name is of the expected type

    ex:

    const actual = {foo: 42, bar: 'foo', baz: false};

    havingProps(['foo', ['bar', 'string']])
    .setActual(actual)
    .compare(); // returns `true`

    havingProps([['foo': 'string'], 'bar', 'baz'])
    .setActual(actual)
    .compare(); // returns `false` because 'foo' is type `number`

    havingProps(['foobar'])
    .setActual(actual)
    .compare(); // returns `false` because no property named `foobar`

    await aftTest('example havingProps', async () => {
    await t.verify(actual, havingProps(['foo', ['bar', 'string']])); // succeeds
    });

    Parameters

    • expected: (string | string[])[]

      an array of either property name strings or arrays of property name and property type strings like [['propName', 'propType']]

    Returns HavingProperties

    a new HavingProperties instance

Generated using TypeDoc