Check if a string contains 'abc' or 'cde' with jest

You can use toContain Jest matcher https://jestjs.io/docs/en/expect#tocontainitem

.toContain(item)

Use .toContain when you want to check that an item is in an array. For testing the items in the array, this uses ===, a strict equality check. .toContain can also check whether a string is a substring of another string.

For example, if getAllFlavors() returns an array of flavors and you want to be sure that lime is in there, you can write:

test('the flavor list contains lime', () => {
 expect(getAllFlavors()).toContain('lime');
});

You can use a regexp with toMatch

like :

expect(str).toMatch(/(abc|cde)/i)