2017-08-12 145 views
0

你好我怎樣才能和Jest一起使用ES6。因爲他們給我傳播(運營商)和出口的錯誤。 如何修改jest?Jest ES6錯誤意外令牌導入?

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 
 
     }) 
 
    }) 
 
})

+0

有一個在代碼中沒有傳播經營者,你已經發布。 – estus

+0

你在這裏得到的錯誤是什麼? –

+0

意外令牌導入 –

回答

0

開玩笑配置文件

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

依賴

NPM我--D開玩笑,開玩笑CLI-通天預處理器

再見