I have a module ./main.js
that I am trying to test using ./__tests__/main-test.js
. ./main.js
uses new Regexp(REGEX, 'g')
in one of its exported functions.
Running jest
produces this error:
ReferenceError: Regexp is not defined
I thought it may be a mocking problem and added jest.unmock('Regexp')
to main-test.js
(even though it's not a required module), but got the same result.
What isn't Regexp
defined?
I have a module ./main.js
that I am trying to test using ./__tests__/main-test.js
. ./main.js
uses new Regexp(REGEX, 'g')
in one of its exported functions.
Running jest
produces this error:
ReferenceError: Regexp is not defined
I thought it may be a mocking problem and added jest.unmock('Regexp')
to main-test.js
(even though it's not a required module), but got the same result.
What isn't Regexp
defined?
1 Answer
Reset to default 18Cause it should be RegExp
, case sensitive, remember? otherwise the interpreter is searching for an object called Regexp
which is not the desired RegExp constructor.