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

137
Visualizações
How to test two parameters to be numbers with Jest

I got a function which receives two numbers (integer), returning an array with the firsts (numbers) multiple of (value) like countBy(value, number).

e.g.

countBy(1, 10) returns [1, 2, 3, 4, 5, 5, 7, 8, 9, 10]

countyBy(2, 5) returns [2, 4, 6, 8, 10]

So, what matcher should be used to test if the function receives only numbers (integer) ? I did a lot of tests but still did not find a solution.

it ('Verify if are received and returned only numbers', () => {
  expect(typeof countBy(2, 5)).toBe('number'); 
});

Does anybody can give me a light?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

try this

const targetArray = [1, 2, 3, 4, 5, 5, 7, 8, 9, 10];

test("Verify if are received and returned only numbers", () => {
  targetArray.forEach((target) => {
    expect(typeof target).toBe("number");
  });
});
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