whatwg-fetch语法错误:意外的字符串

时间:2019-01-18 11:25:37

标签: javascript

我想使用此访存polyfil,以便可以使用jest对我的sdk进行集成测试。

但是,当我运行测试时,我得到了。

 /jest.setup.js:2
    import 'whatwg-fetch';
           ^^^^^^^^^^^^^^
    SyntaxError: Unexpected string

jest.config.js

// File jest.config.js
module.exports = {
    "verbose": true,
    setupFiles: ['./jest.setup.js'],
};

jest.setup.js

// File jest.setup.js
import 'whatwg-fetch';

package.json

    "scripts": {
        "test": "jest"
    },
    "devDependencies": {
        "@babel/core": "^7.2.2",
        "@babel/preset-env": "^7.2.3",
        "babel-jest": "^23.6.0",
        "babel-loader": "^8.0.5",
        "babel-preset-es2015": "^6.24.1",
        "copy-webpack-plugin": "^4.6.0",
        "jest": "^23.6.0",
        "uglifyjs-webpack-plugin": "^2.1.1",
        "webpack": "^4.28.4",
        "webpack-cli": "^3.2.1",
        "whatwg-fetch": "^3.0.0"
    }

0 个答案:

没有答案