Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Jest toContain

# 1. Use '.toContain' when you want to check that an item is in an array.
# 2 '.toContain' can also check whether a string is a substring of another string.
test('the flavor list contains lime', () => {
  expect(['lime', 'mangle']).toContain('lime');
});

test('the flavor list contains lime', () => {
  expect("lime juice").toContain('lime');
});
Source by jestjs.io #
 
PREVIOUS NEXT
Tagged: #Jest #toContain
ADD COMMENT
Topic
Name
1+3 =