Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
Jest compare arrays WITH ORDER

Everything which I've searched is always without/ignoring order.
I want to compare 2 arrays with order.

expect([1, 2, 3].concat(4)).toEqualWithOrder([1, 2, 3, 4])

expect([{ value: 1}, { value: 2}, { value: 3 }].concat({ value: 4 })
.toEqualWithOrder([
  { value: 1 },
  { value: 2 },
  { value: 3 },
  { value: 4 },
])

How can I do that with Jest? Should we use JSON.stringify?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Just use the normal .toEqual method. It does require the items to appear in the same order.

Only to deviate from that you'd need a special method.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda