我一直在尝试在 karma 中使用生成器,我已经阅读了很多我需要在测试文件之前包含 polyfill 文件的内容karma.conf.js
。
这是我的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
}
我在我的传奇中做错了什么吗?还是巴别塔?或者别的地方?任何帮助,将不胜感激