Javascript 玩笑以“停止”;SyntaxError:意外标记';出口'&引用;虽然我';我们设置了transformIgnorePatterns
我正在运行Javascript 玩笑以“停止”;SyntaxError:意外标记';出口'&引用;虽然我';我们设置了transformIgnorePatterns,javascript,vue.js,jestjs,babel-jest,Javascript,Vue.js,Jestjs,Babel Jest,我正在运行npm run test,它运行jest,但测试套件失败,并显示以下消息: /home/anthony/nosync/development/openmeteo/enhydris-web-frontend/node_modules/vue-notifications/dist/vue-notifications.js:130 export default VueNotifications; SyntaxError: Unexpected token 'export' 以下是jest
npm run test
,它运行jest
,但测试套件失败,并显示以下消息:
/home/anthony/nosync/development/openmeteo/enhydris-web-frontend/node_modules/vue-notifications/dist/vue-notifications.js:130
export default VueNotifications;
SyntaxError: Unexpected token 'export'
以下是jest.config.js
中的相关配置:
transform: {
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest',
},
transformIgnorePatterns: ['node_modules/(?!(vue-notifications)/)'],
我还经常运行npm运行测试--clearCache
以确保安全。但是transformIgnorePatterns
似乎没有任何效果
如您所见,错误消息的第一行以:130
结尾。这个号码是多少?是发生错误的行号吗?实际上,导出默认VueNotifications
行是第117行。如果我添加一些空行来向下移动它,我仍然会得到:130
。(如果我把它注释掉,问题就消失了,当然测试仍然失败,因为需要导出。)这似乎是一个-transformIgnorePatterns不适用于.babelrc
,只适用于babel.config.js
。我将我的.babelrc
转换为.babel.config.js
,现在可以使用了