expect.not.stringContaining(string)

expect.not.stringContaining(string) matches the received value if it is not a string or if it is a string that does not contain the exact expected string.

It is the inverse of expect.stringContaining.

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