最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Regexp is not defined in Jest test - Stack Overflow

programmeradmin1浏览0评论

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?

Share Improve this question asked Mar 17, 2016 at 21:08 Matt NorrisMatt Norris 8,83614 gold badges60 silver badges92 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

Cause it should be RegExp , case sensitive, remember? otherwise the interpreter is searching for an object called Regexp which is not the desired RegExp constructor.

发布评论

评论列表(0)

  1. 暂无评论