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

247
Views
Writing list of tests in jest by defining list of inputs/expected outputs

I would like to write a set of tests in jest for the same function:

Lets say I have a function which adds numbers together

function add(a, b) {
  return a + b;
}

Now I would like to write a set of tests which check a set of inputs to this function e.g.

Test Name Inputs Expected Output
Positive Numbers {a:1,b:5} 6
First Negative {a: -1, b:5} 4
Second Negative {a:1, b:-5} -4
Both Negative {a: -1, b:-5} -6

Also I would ideally have multiple cases for each test e.g. for Positive Numbers

{{a:1, b:5, out: 6}, {a:4, b:7, out: 11}, {a:2, b:20, out:22}}

How could I go about doing this?

about 4 years ago · Santiago Trujillo
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!