我一直在尝试在业力中使用生成器,我已经阅读了很多我需要在karma.conf.js
中的测试文件之前包含polyfill文件。
这是我的karma.conf.js
文件:
let webpackConfig = require('./webpack.config.js');
webpackConfig.entry = './src/index.js';
config = {
frameworks: ['mocha', 'chai', 'sinon'],
files: [
'./node_modules/babel-polyfill/dist/polyfill.js',
// './node_modules/babel-polyfill/browser.js',
'./test/tests.webpack.js'
],
preprocessors: {
'./src/index.js': ['webpack', 'sourcemap'],
// './src/**/*.js': ['webpack', 'sourcemap'],
'./test/tests.webpack.js': ['webpack', 'sourcemap'],
},
webpack: webpackConfig,
...
}
但每次运行karma start
时都会出现此错误:
Uncaught TypeError: Cannot read property '2' of undefined
如果我在polyfill
中有files
文件,则只会显示,如果我将其删除,我会收到此错误:RegeneratorRuntime is not defined
我追踪了这个错误,它来自这个(redux-saga)
var _marked = [selectedDataChanged, selectedInfoChanged, stockAppSaga].map(regeneratorRuntime.mark);
function stockAppSaga() {
return regeneratorRuntime.wrap(function stockAppSaga$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return [
// takeEvery(
// [actionTypes.SELECTED_TICKER_CHANGED, actionTypes.SELECTED_DATE_CHANGED],
// selectedInfoChanged
// ),
(0, _effects.takeEvery)([actionTypes.SELECTED_TICKER_CHANGED, actionTypes.SELECTED_DATE_CHANGED], selectedDataChanged)];
case 2:
case 'end':
return _context3.stop();
}
}
}, _marked[2], this); // this is the error line
}
我的传奇中有什么问题吗?还是巴贝尔?或者别的地方?任何帮助将不胜感激