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

133
Vistas
Writing a test case for a condition where the data is an array that generates many data using a function

This is the function that is in the mockData folder


export const generateNotificationMockMany = (count) => (
    [...new Array(count)].map((index) => ({
            'group': `group number ${index}`,
            'message': `msg for group number ${index}`,
            'datetime': '',
        }),
    ));




this is the test case I've been trying to write. the data is being imported from a file that has this function in it that generates the mockdata. How can I write the test case for it? basically how can I use a loop to be able to get access to all the generated data by the function?

it('renders properly for the many variant', ()=> {
        render(<NotificationMenu notifications={notificationsMock}/>)

    });

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

0

Does one of the following options solve your problem, or do you expect something else ?

loop over test cases:

const mocks = generateNotificationMockMany(10);

for (let notificationsMock of mocks) {
  it(`renders properly for the variant ${notificationsMock}`, ()=> {
    render(<NotificationMenu notifications={notificationsMock}/>)
  });
}

loop inside test case:

const mocks = generateNotificationMockMany(10);

it(`renders properly for the many variant`, ()=> {
  for (let notificationsMock of mocks) {
    render(<NotificationMenu notifications={notificationsMock}/>)
  }
});
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