expect.not.stringMatching(string | regexp)

expect.not.stringMatching(string | regexp) matches the received value if it is not a string or if it is a string that does not match the expected string or regular expression.

It is the inverse of expect.stringMatching.

  1. describe('not.stringMatching', () => {
  2. const expected = /Hello world!/;
  3. it('matches if the received value does not match the expected regex', () => {
  4. expect('How are you?').toEqual(expect.not.stringMatching(expected));
  5. });
  6. });