Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!