I would like to check if a string contains 'abc' or 'cde' with jest.
const substr1 = 'abc' const substr2 = 'cde' const str = 'ooocdeooo'
I am using
expect(str).toContain(substr1);
for one string but I cant find a clean way to check whether substr1 or substr2 is in str How could I do that ? Thanks !
You can use a regexp with toMatch
like :
expect(str).toMatch(/(abc|cde)/i)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With