Provide CommonJS modules
Shyam-Chen opened this issue · 2 comments
Shyam-Chen commented
Version: 1.1.2
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/Users/.../node_modules/vue-router-prefetch/dist/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){var e="undefined"!=typeof window,t=e&&navigator.connection,n=e&&(!t||-1===(t.effectiveType||"").indexOf("2g")&&!t.saveData),r=e&&window.IntersectionObserver,o={};function i(e){return new Promise(function(t,n){var r=new XMLHttpRequest;r.open("GET",e,r.withCredentials=!0),r.addEventListener("load",function(){200===r.status?t():n()}),r.send()})}var s=function(t){if(e){var n=document.createElement("link");return n.relList&&n.relList.supports&&n.relList.supports(t)}}("prefetch")?function(e){return new Promise(function(t,n){var r=document.createElement("link");r.rel="prefetch",r.href=e,r.addEventListener("load",t),r.addEventListener("error",n),document.head.appendChild(r)})}:i;function c(e,t){if(n&&!o[e])return(t?function(e){return self.fetch?fetch(e,{credentials:"include"}):i(e)}:s)(e).then(function(){o[e]=!0})}export default f
SyntaxError: Unexpected token export
egoist commented
PR welcome!
egoist commented
🎉 This issue has been resolved in version 1.2.0 🎉
The release is available on:
Your semantic-release bot 📦🚀