0

您好,我如何将 ES6 与 Jest 一起使用。因为他们在传播(运营商)和出口方面向我发送了错误。如何修改笑话?

export default function reducer(state={
    open:false
  }, action) {

    switch (action.type) {
      case "HANDLE_TAP_HOME": {
        return {...state,open:action.open}
        
      }
    }

    return state
}

测试

import base from '../../client/src/redux/reducer/reducers/Admin/base/Index'

describe('request to Reducer',()=>{
    it('fetch',()=>{
        expect(base(undefiend,{type:'nothing'})).toEqual({
            open:false
        })
    })
})

4

1 回答 1

1

笑话配置文件

"jest": {
    "scriptPreprocessor": "<rootDir>/node_modules/jest-babel-preprocessor/preprocessor.js",
    "unmockedModulePathPatterns": [
      "<rootDir>/node_modules/react"
    ]
  }

依赖关系

npm i --D jest-cli jest-babel-preprocessor

再见

于 2017-08-13T06:38:18.590 回答