Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 运行karma/Ezyme测试时,只允许安装一次babel polyfill_Reactjs_Karma Runner_Babeljs_Enzyme_Babel Polyfill - Fatal编程技术网

Reactjs 运行karma/Ezyme测试时,只允许安装一次babel polyfill

Reactjs 运行karma/Ezyme测试时,只允许安装一次babel polyfill,reactjs,karma-runner,babeljs,enzyme,babel-polyfill,Reactjs,Karma Runner,Babeljs,Enzyme,Babel Polyfill,当我用酶运行karma测试时,我得到一个错误: only one instance of babel-polyfill is allowed at ... 是导致此错误的测试文件: import React from 'react'; import { Provider } from 'react-redux'; import configureStore from '../../src/common/store/configureStore'; import { shallow,mount

当我用酶运行karma测试时,我得到一个错误:

only one instance of babel-polyfill is allowed at ...
是导致此错误的测试文件:

import React from 'react';
import { Provider } from 'react-redux';
import configureStore from '../../src/common/store/configureStore';
import { shallow,mount } from 'enzyme';
import ChatContainer from '../../src/common/containers/ChatContainer';


const initialState = window.__INITIAL_STATE__;
const store = configureStore(initialState);




describe('ChatContainer Component', () => {
    let Component;

    beforeEach(() => {
        Component = 
            mount(<Provider store={store}>
                <ChatContainer />
            </Provider>);
    });

    it('should render', () => {
        expect(Component).toBeTruthy();
    });


});
这是我的网页配置:

var path = require('path');
var webpack = require('webpack');

module.exports = {
  devtool: 'inline-source-map',
  entry: [
    'babel-polyfill',
    'webpack-hot-middleware/client',
    './src/client/index'
  ],
  output: {
    path: path.resolve(__dirname, './static/dist'),
    filename: 'bundle.js',
    publicPath: '/dist/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
      }
    })
  ],
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        query: {
          plugins: [,
            [
              'react-transform', {
                transforms: [{
                  transform: ['react-transform-hmr']
                  imports: ['react'],
                  locals: ['module']
                }, {
                  transform: 'react-transform-catch-errors',
                  imports: ['react', 'redbox-react']
                }]
              }
            ]
          ]
        },
        include: [path.resolve(__dirname, 'src')]
      },
      {
        test: /\.css?$/,
        loaders: ['style', 'raw']
      }
    ]
  }
};
var path = require('path');
var webpack = require('webpack');

module.exports = {
  devtool: 'inline-source-map',
  entry: [
    'babel-polyfill',
    'webpack-hot-middleware/client',
    './src/client/index'
  ],
  output: {
    path: path.resolve(__dirname, './static/dist'),
    filename: 'bundle.js',
    publicPath: '/dist/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
      }
    })
  ],
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        query: {
          plugins: [,
            [
              'react-transform', {
                transforms: [{
                  transform: ['react-transform-hmr']
                  imports: ['react'],
                  locals: ['module']
                }, {
                  transform: 'react-transform-catch-errors',
                  imports: ['react', 'redbox-react']
                }]
              }
            ]
          ]
        },
        include: [path.resolve(__dirname, 'src')]
      },
      {
        test: /\.css?$/,
        loaders: ['style', 'raw']
      }
    ]
  }
};