Valentin Vignal
Valentin Vignal

Reputation: 8240

How to combine matchers

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 ?

Upvotes: 2

Views: 82

Answers (1)

Valentin Vignal
Valentin Vignal

Reputation: 8240

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:

Upvotes: 4

Related Questions