gpt4 book ai didi

testing - 错误 : : fetch() method does not exist in PhantomJS

转载 作者:行者123 更新时间:2023-11-28 20:50:32 26 4
gpt4 key购买 nike

我正在使用 PhantomJS 来运行测试。

并得到以下错误:

Error: : fetch() method does not exist

这是 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
});
};

最佳答案

尝试将 whatwg-fetch polyfill 添加到您的 karma.config.js

files: [
'node_modules/whatwg-fetch/fetch.js',
...
]

关于testing - 错误 : <spyOn> : fetch() method does not exist in PhantomJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49067432/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com