Reputation: 11
Hello how can I use ES6 with Jest. Because they send me a mistake in spread (operator) and export. How to modify jest?
export default function reducer(state={
open:false
}, action) {
switch (action.type) {
case "HANDLE_TAP_HOME": {
return {...state,open:action.open}
}
}
return state
}
test
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
})
})
})
Upvotes: 0
Views: 633
Reputation: 11
jest configuration file
"jest": {
"scriptPreprocessor": "<rootDir>/node_modules/jest-babel-preprocessor/preprocessor.js",
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/react"
]
}
dependencies
npm i --D jest-cli jest-babel-preprocessor
bye
Upvotes: 1