to have items satisfying
- <array-like> to have items [exhaustively] satisfying <assertion>
- <array-like> to have items [exhaustively] satisfying <any>
Asserts that all items of an array (or array-like object) satisfy a given assertion or function.
Alias: to be an array whose items satisfy
.
Notice this assertion fails when given an empty array.
expect([0, 1, 2, 3, 4],'to have items satisfying',expect.it(function (item) {expect(item, 'to be a number');}));expect([0, 1, 2, 3, 4], 'to have items satisfying', 'to be a number');expect([[1], [2]],'to have items satisfying','to have items satisfying','to be a number');expect([1, 2, 3, 4],'to have items satisfying',expect.it('to be a number').and('to be positive'));
In case of a failing expectation you get the following output:
expect([[0, 1, 2],[4, '5', '6'],[7, '8', 9],],'to have items satisfying','to have items satisfying','to be a number');
expected array to have items satisfying to have items satisfying to be a number[[ 0, 1, 2 ],[4,'5',//should be a number'6'//should be a number],[7,'8',//should be a number9]]
Here a another example:
expect([0, 1, 2, 3, 4],'to have items satisfying',expect.it('to be a number').and('to be positive'));
expected [ 0, 1, 2, 3, 4 ] to have items satisfyingexpect.it('to be a number').and('to be positive')[0,////✓andshould be a number⨯should be positive1,2,3,4]