How to combine matchers

51 Views Asked by At

I have a test like:

const myText = 'This is my test';

expect(myText, contains('This'));
expect(myText, contains('test'));

How can I combine those 2 matchers to have only 1 expect ?

1

There are 1 best solutions below

0
On BEST ANSWER

You can combine the matchers with allOf:

const myText = 'This is my test';

expect(myText, allOf([contains('This'), contains('test')]));

More generally, you can combine any matchers using: