Javascript CircleCI中的React应用程序:运行jest时失败

Javascript CircleCI中的React应用程序:运行jest时失败,javascript,reactjs,jestjs,circleci,Javascript,Reactjs,Jestjs,Circleci,我有一个反应,它在CircleCI中失败,原因如下: #!/bin/bash -eo pipefail yarn test yarn run v1.5.1 $ jest FAIL src/Form.test.js ● Test suite failed to run Cannot find module './Store' from 'Form.js' However, Jest was able to find: './Form.js'

我有一个反应,它在CircleCI中失败,原因如下:

#!/bin/bash -eo pipefail
yarn test
yarn run v1.5.1
$ jest
 FAIL  src/Form.test.js
  ● Test suite failed to run

    Cannot find module './Store' from 'Form.js'

    However, Jest was able to find:
        './Form.js'
        './Form.test.js'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node', 'test.js', 'css'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

      1 | import React from 'react';
      2 | import { Form, Input, Button } from 'reactstrap';
    > 3 | import { actions } from './Store';```
我的
Store.js
文件就是包含操作、还原程序等的js文件:

import { createStore, combineReducers } from 'redux';

const initialState = {
  characters: []
};

// Actions
export const actions = {
  addChar: ch => {
    return {
      type: 'ADD_CHAR',
      payload: ch
    };
  },

  addAllChars: characters => {
    return { type: 'ADD_ALL_CHARS', payload: { characters: characters } };
  },
  increment: () => {
    return { type: 'INCR' };
  },
  decrement: () => {
    return { type: 'DECR' };
  }
};

// Reducers
function charReducer(state = {}, action) {
  switch (action.type) {
    case 'ADD_ALL_CHARS': {
      return action.payload.characters;
    }
    case 'ADD_CHAR': {
      let newest = [...state];
      let char = {
        ...action.payload,
        id: newest.length + 1
      };
      newest.push(char);
      return newest;
    }
    default:
      return state;
  }
}

const appReducer = combineReducers({
  characters: charReducer
});

// Store
export const store = createStore(appReducer, initialState);
// Debug
window.store = store;
window.actions = actions;
例如,
Form.js
文件的开头是:

import { Form, Input, Button } from 'reactstrap';
import { actions } from './Store';
import { connect } from 'react-redux';
babel.config.js
是:

module.exports = {
  presets: ['@babel/preset-env', '@babel/preset-react'],
  plugins: [
    '@babel/plugin-transform-arrow-functions',
    '@babel/plugin-proposal-class-properties'
  ]
};
    "moduleNameMapper": {
      "\\.(css|less)$": "identity-obj-proxy",
      "\\.(jpg|gif|ttf|eot|svg)$": "<rootDir>/__mocks__/fileMock.js"
    },
    "moduleFileExtensions": [
      "js",
      "json",
      "jsx",
      "ts",
      "tsx",
      "node",
      "test.js",
      "css"
    ]
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "jest",
    "eject": "react-scripts eject"
  },
而包.json的一部分是:

module.exports = {
  presets: ['@babel/preset-env', '@babel/preset-react'],
  plugins: [
    '@babel/plugin-transform-arrow-functions',
    '@babel/plugin-proposal-class-properties'
  ]
};
    "moduleNameMapper": {
      "\\.(css|less)$": "identity-obj-proxy",
      "\\.(jpg|gif|ttf|eot|svg)$": "<rootDir>/__mocks__/fileMock.js"
    },
    "moduleFileExtensions": [
      "js",
      "json",
      "jsx",
      "ts",
      "tsx",
      "node",
      "test.js",
      "css"
    ]
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "jest",
    "eject": "react-scripts eject"
  },

请提供导致此错误的示例代码。看到它在本地失败了吗?@emilebergron它只是在循环中失败了单击提示:
increment:()=>({type:'INCR'}),
不需要以这种方式显式返回。)也许circleci配置也会有所帮助。请提供导致此错误的示例代码。看到它在本地失败了吗?@emilebergron它只是在循环中失败了单击提示:
increment:()=>({type:'INCR'}),
不需要以这种方式显式返回。)也许circleci配置也会有所帮助。