Answers for "jest check if is array"

1

jest check array of string

const fruits = ['apple', 'cat'];

test('should have array of string', () => {
  expect(fruits).toEqual(
    expect.arrayContaining([expect.any(String)])
  );
});
Posted by: Guest on April-06-2021
0

jest check array of objects

test('id should match', () => {
  const obj = {
    id: '111',
    productName: 'Jest Handbook',
    url: 'https://jesthandbook.com'
  };
  expect(obj.id).toEqual('111');
});
Posted by: Guest on October-28-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language