Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jest test array of objects

const users = [{id: 1, name: 'Hugo'}, {id: 2, name: 'Francesco'}];

test('we should have ids 1 and 2', () => {
  expect(users).toEqual(
    expect.arrayContaining([
      expect.objectContaining({id: 1}),
      expect.objectContaining({id: 2})
    ])
  );
});
Comment

jest check array of string

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

test('should have array of string', () => {
  expect(fruits).toEqual(
    expect.arrayContaining([expect.any(String)])
  );
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: electron inspect 
Javascript :: random light color js 
Javascript :: regular expression for password 
Javascript :: useFetch custom hook for React 
Javascript :: js exec vs match 
Javascript :: access url query string from javascript 
Javascript :: js camel case to snake case 
Javascript :: references another schema in sequelize 
Javascript :: jquery delay 
Javascript :: date to seconds js 
Javascript :: thinkful 
Javascript :: js computed style 
Javascript :: display image base64 in REACT NATIVE 
Javascript :: dm someone by id discord.js 
Javascript :: remove special characters javascript 
Javascript :: find the key of a value in array js 
Javascript :: change object key name javascript es6 
Javascript :: if checkbox is checked jquery 
Javascript :: console log returns object object nodejs 
Javascript :: give div event listener functional component 
Javascript :: moment js convert to local timezone 
Javascript :: js union arrays 
Javascript :: jquery trigger link click 
Javascript :: vuejs send required props to dynamic component 
Javascript :: url redirect javascript 
Javascript :: vehicle number yup validation 
Javascript :: nodejs express api 
Javascript :: disemvowel trolls codewars javascript 
Javascript :: jquery get selected text from multiselect 
Javascript :: remove null and undefined from array 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =