我正在使用PhantomJS来运行测试。
并收到以下错误:
错误:: fetch()方法不存在
这是karma.config.js文件:
var webpackConfig = require('./webpack.config.js');
module.exports = config => {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: ['node_modules/babel-polyfill/dist/polyfill.js','./src/components/**/*.spec.ts'],
preprocessors: {
'./src/components/**/*.spec.ts': ['webpack']
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
webpack: webpackConfig,
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false,
webpackMiddleware: {
noInfo: true
},
concurrency: Infinity
});
};
答案 0 :(得分:1)
尝试将whatwg-fetch polyfill添加到您的karma.config.js
files: [
'node_modules/whatwg-fetch/fetch.js',
...
]