Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!