开玩笑的问题“ ReferenceError:未定义测试”

时间:2020-09-29 20:46:55

标签: javascript jestjs

我对Jest和Webstorm有一个小问题。我看到其他线程解释了这个问题可能与node.js或jest的版本有关,但对我而言,它们都是最新的。 仅当我一次尝试执行一个测试时,才会发生这种情况,但是当所有这些测试都起作用时,就会发生这种情况。

JEST VERSION 26.4.2

节点版本 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();
});

谢谢

0 个答案:

没有答案