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

338
Vistas
Deep equal comparing not working on Cypress 9.7.0

I've updated my cypress to 9.7.0 version and right now I have a problem with deep equal. When I wrote test line of code:

expect([1,2,3]).to.deep.equal([1,2,3]);

enter image description here

Everything works correctly.

While I'm testing redux store I got an error which is looks

Timed out retrying after 4000ms: expected [ Array(2) ] to deeply equal [ Array(2) ]

enter image description here

Arrays in devtool console preview are the same... I've tried in two ways to write test. I also combined it with async and timeouts

First try:

it('Example redux check', () => {
        cy.fixture('file.json').then((fixtures) => {
            cy.window()
                .its('store')
                .invoke('getState')
                .its('queue.queueItems').should('deep.equal', fixtures.store.queue.queueItems);
        });
    });

Second try

it('Example redux check', () => {
    cy.fixture('file.json').then((fixtures) => {
        const getQueueItems = (win) => {
            return win.store.getState().queue.queueItems;
        }

         cy.window()
             .pipe(getQueueItems)
             .should('deep.equal', fixtures.store.queue.queueItems);
    });
});

Had anyone similar issue or idea how to avoid that timeout? Exactly the same is happening while comparing async payloads...

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

0

I couldn't fault the deep.equal assertion in Cypress v9.7.0, even deeply nested arrays and objects - except when the order differed.

If your problem is difference in array order, try adding package deepEqualInAnyOrder

const deepEqualInAnyOrder = require('deep-equal-in-any-order');
chai.use(deepEqualInAnyOrder);

it('matches when ordering is different', () => {
  
  const expected = [{a:{x:1}}, {b:2},{c:3}];

  expect([{a:{x:1}}, {b:2}, {c:3}]).to.deep.equal(expected)            // passes
  expect([{b:2}, {a:{x:1}}, {c:3}]).to.deep.equal(expected)            // fails

  expect([{b:2}, {a:{x:1}}, {c:3}]).to.deep.equalInAnyOrder(expected)  // passes

});
about 4 years ago · Juan Pablo Isaza Denunciar

0

I also wanted to see if deep.equal on the <h1> element of http://example.com would succeed.

Here is my minimal, reproducible example.

// Cypress 9.7.0

it('passes deep-equal of two DOM objects', () => {
  cy.visit('http://example.com')

  cy.get('h1').then($el1 => {                  // get h1 1st time
    cy.get('h1').then($el2 => {                // get another copy

      // Are they different objects?
      expect($el1).to.not.equal($el2)           // pass
      expect($el1 === $el2).to.equal(false)     // pass 

      // Do they deep-equal
      expect($el1).to.deep.equal($el2)          // pass
      
    })
  })
})

enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar

0

Nearly all frontends I use have Cypress including some open source ones.

It is related to a few issues opened on GitHub and affects latest versions of Cypress.

https://github.com/cypress-io/cypress/issues/21353

https://github.com/cypress-io/cypress/issues/21469

This is what I get on a WIP after upgrading some tests that use deep.equal:

Error with deep equal

Your first example looks more standard.

I recommend downgrading to a lower version. The following version worked for me before upgrade:

9.5.4

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