Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda