How to check for object properties match for an object using Jest?

Try to use expect.objectContaining() and expect.any() to check each property type.

    import location from './whatever'
    describe('location', () => {
      it('should return location object', () => {
        expect(location()).toEqual(expect.objectContaining({
          locationId: expect.any(Number),
          geo: expect.any(Array),
          isFetching: expect.any(Boolean)
        }))
      })
    })

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)