Quantcast
Channel: jest.mock of ES6 class yields ReferenceError: require is not defined - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by ezze for jest.mock of ES6 class yields ReferenceError: require is...

You have to disable any source code transformations in order to make it working by setting{ transform: {}}in your Jest configuration file. By default transform option is configured to use babel-jest....

View Article



jest.mock of ES6 class yields ReferenceError: require is not defined

I'm trying to create an automatic mock using jest in my ES6 javascript project.I'm using node v15.0.1, and jest 26.6.0 on ubuntu 18.04.5.I have a test file containing the following code:import...

View Article

Answer by Mark Langer for jest.mock of ES6 class yields ReferenceError:...

You also get the error ReferenceError: require is not defined if one of the files you import has the term mock in it, e.g. generate-user-mock.ts. This is a hidden contract entering some sort of special...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>