๐ŸŽtoContain

Check if something is contained in something

This comparison is used to determine if an Array contains a value.

All the values returned by T[index] will be compared using the == operator, so overloading the class @operator("==") can be used in conjunction with this comparison. The index must be a number value, and there must be a length property that matches the index type. All values from 0 to length - 1 will be checked.

const data = new Uint8Array(100);
data[5] = 255;

expect(data).toContain(255);

This method is portable with jest using the toContain() method.

Last updated