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

161
Vistas
set up function not found?

I have a helper function helper and a setup function setUp in my tests. The helper works fine, but the setup function returns an error, because it is not found. Why? Am I missing something obvious?

function helper(arg){
  return arg+1
}

function setUpSpy(){
  let spy;

  beforeEach(()=>{
    spy = sinon.spy()
    document.addEventListener('message', spy);
  })

  afterEach(()=>{
    document.removeEventListener('message', spy);
  })
  return spy
}


describe('does a thing', function(){
  let spy = setUpSpy() // FAILS

  it('via an event', async function(){
    const app = new window.App()
    await app.init()
    console.log(helper(1)) // WORKS

    assert.equal(spy.callCount,1)
  });
});

Error returned:

 TypeError: Cannot read properties of undefined (reading 'callCount')
about 4 years ago · Juan Pablo Isaza
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