Jest issue "ReferenceError: test is not defined"

Viewed 423

I have a small issue with Jest and Webstorm. I saw other threads that explained that this problem was maybe related to the version of node.js or jest but for me they are all up to date. This happen only when I tried to execute one test at the time but when do all of them it worked.

JEST VERSION 26.4.2

NODE VERSION v14.9.0

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

module.exports = sum;
const sum = require('./sum');

test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3);
});

test('adds 2 + 2 to equal 4', () => {
  expect(sum(2, 2)).toBe(4);
});

test('null', () => {
  const n = null;

  expect(n).toBeNull();
  expect(n).toBeDefined();
  expect(n).not.toBeUndefined();
  expect(n).not.toBeTruthy();
  expect(n).toBeFalsy();
});

Thank you

0 Answers
Related