[Solved] npm test fails to run when module imported

Faith Baghan Asks: npm test fails to run when module imported
I have installed a @{SourceModule}/{SubModule} and imported it in the App.js file in my React project.

The app is working as expected when using npm start. However running npm test fails with the following log:

Code:
 FAIL  src/App.test.js
● Test suite failed to run

ReferenceError: regeneratorRuntime is not defined

> 1 | import TestModule from "@{SourceModule}/{SubModule}";
    | ^


  at node_modules/@{SourceModule}/{SubModule}/dist/index.js:3628:46
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/index.js:3657:2)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/components/components/Timeline/index.js:10:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/components/components/TimelineEditor/Helpers.js:1:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/components/components/TimelineEditor/EventHub.js:3:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/components/widgets/Vec3Widget.js:5:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/components/components/PropertyRow.js:13:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/components/components/Component.js:4:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/components/components/ComponentsContainer.js:4:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/components/components/Sidebar.js:3:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/components/Main.js:6:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/src/index.js:16:1)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/index.js:29901:18)
  at __webpack_require__ (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:19:1)
  at node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/bootstrap 67aaffd607fcdcc03468:65:1
  at node_modules/@{SourceModule}/{SubModule}/dist/index.js:79:10
  at webpackUniversalModuleDefinition (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/universalModuleDefinition:3:1)
  at Object.<anonymous> (node_modules/@{SourceModule}/{SubModule}/dist/webpack:/webpack/universalModuleDefinition:10:2)
  at Object.<anonymous> (src/App.js:2:1)
  at Object.<anonymous> (src/App.test.js:2:1)

I have tried installing and importing core-js/stable and regenerator-runtime in my app index.js (and not in the module), but it doesn’t seem to help. Is this something I could solve from my side or I should apply this/any other solution to the module itself?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.