Chai.js - Check if string contains substring from a list
expect(thatSelectedItem).to.contain.oneOf(['jpg', 'png', 'gif'])
This lands with v4.3.0 (docs). oneOf
can be chained with contain
, contains
, include
and includes
, which will work with both arrays and strings. It's strongly recommended to use because the error messages you get with it are much cleaner.
With plain Chai (no additional plugins), you can use match
:
expect(thatSelectedItem).to.match(/(?:jpg|png|gif)/)