' import 'promise-polyfill/src/polyfill' 'has syntaxerror when i excute 'npm run test'
Closed this issue · 2 comments
jinmawang commented
`/Users/zhangjinma/Work/discovery/node_modules/promise-polyfill/src/polyfill.js:1
({"Object.":function(module,exports,require,__dirname,__filename,global,jest){import Promise from './index';
^^^^^^
SyntaxError: Cannot use import statement outside a module
1 | import axios from 'axios';
2 | import { INTERFACE_BASE_URL } from '../config/constants';
> 3 | import 'promise-polyfill/src/polyfill';
| ^
`
jinmawang commented
this is a react app created by CRA,Jest and Jest-Babel is enabled by default
taylorhakes commented
The polyfill needs to be compiled. If you want the compiled version use import 'promise-polyfill/dist/polyfill'