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
Jest saying "Not a function" when it is defined as function

I am writing jest for this simple function:

function isVowel(ch) {
  ch = ch.toUpperCase();

  return ch == "A" || ch == "E" || ch == "I" || ch == "O" || ch == "U";
}

this is the jest:

const isVowel = require("./isVowel");
test("a is vowel", () => {
  const ch = isVowel("a");
  expect(ch).toBe("A");
});

on running, it gives error: TypeError: isVowel is not a function

how to resolve it?

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I assume you write your code in commonjs format due to the way you require it in your test file so you just simply export like this:

// isVowel.js

function isVowel(ch) {
  ch = ch.toUpperCase();

  return ch == "A" || ch == "E" || ch == "I" || ch == "O" || ch == "U";
}

module.exports = isVowel;
almost 4 years ago · Santiago Trujillo 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!