score:1
since you export your raw component
export { projectpageui as projectpageuicomponent }
you can test it directly without the need to mock up a redux provider and store
import { projectpageuicomponent } from '.'; // import raw component
...
test('shallow-render without crashing', () => {
const props = {
match: { params: {} },
project: { /* now mock up a project object for testing */ }
// mock/supply any other required props
}
shallow(<projectpageuicomponent {...props} />)
});
have you considered react-testing-library
? imo it is a much cleaner way to test ui components. for a simple "renders without crashing" test it is very similar to the above.
score:1
try to wrap you component with redux provider component the makes the redux store available to any nested components that have been wrapped in the connect() function.
shallow(
<provider store={store}>
<projectpageuicomponent {...props} />
</provider>)
score:1
pretty stupid, but it was an issue of wrong importing of the projectpageui
. i imported it as:
import { projectpageuicomponent } from './projectpageui'
which imports the unconnected component, but should have imported the defaults' way:
import projectpageui from './projectpageui'
which worked out
Source: stackoverflow.com
Related Query
- Jest - enzyme testing warning: Failed prop type
- React Snapshot testing with jest - Failed prop type: Invalid prop `children` of type `string` supplied
- how to pass value to prop of type PropTypes.node.isRequired to jest enzyme test?
- Failed prop type warning in unloaded component
- React App - cannot read prop of children (getting undefined) while testing using Jest and Enzyme
- Warning : Failed child context type: Invalid child context 'virtualizedCell.cellKey' of type 'number' supplied to 'CellRenderer', expected 'string'
- Testing with React's Jest and Enzyme when simulated clicks call a function that calls a promise
- Warning: Failed propType: Invalid prop of type `array` expected `object` with React
- Testing with React's Jest and Enzyme when async componentDidMount
- Trigger useEffect in Jest and Enzyme testing
- Testing with Jest failed with Error: Error watching file for changes: EMFILE
- Testing react-router v4 with Jest and Enzyme
- Warning: Failed prop type: Invalid prop `value` of type `number` supplied to `TextInput`, expected `string`
- Warning: Failed prop type: Invalid prop `error` of type `string` expected `boolean`
- React testing component prop change with enzyme
- Testing debounced function in React component with Jest and Enzyme
- Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function`
- React How to fix Failed prop type - Invalid prop of type string expected object
- Set URL params while testing with Jest & Enzyme
- Testing component with react-router v4, Jest and Enzyme
- Enzyme render fails when importing image with webpack while testing with Jest
- ReactWrapper::state() can only be called on class components Unit Testing Jest and Enzyme
- Testing react router v4 with jest enzyme
- Testing React Router with Jest and Enzyme
- Failed prop type: Chat: prop type `room` is invalid; it must be a function, usually from React.PropTypes
- React-router: testing inside the `render` prop with enzyme
- Testing DashJS with Jest & Enzyme
- React testing with Jest and Enzyme (in Symfony) got "Syntax Error: Unexpected token import"
- Failed prop type: Invalid prop `responsive` of type `string` supplied to `Image`, expected `boolean`
- React testing state of component with Jest and Enzyme
More Query from same tag
- How to use an abstract class as the type of a React component in TypeScript?
- Select second element with same class name in testing automation using puppeteer
- Manifest: Line: 1, column: 1, Syntax error on Chrome browser
- Conditionally apply single attribute in react?
- react router - unable to pass store down
- render in react router dom v6
- useSelector destructuring vs multiple calls
- How to show list of data from GET-request
- With Material-UI's DataGrid component, how do I create multi layered text in one of the cells?
- React JSX error trying to use Less Than Symbol
- how can I remove part of data from state in react.js
- how to hide or show a div if checkbox is selected in React JS
- React : retrieve info async with useReducer and useContext
- State is always initial value when attempting to update
- Test that another component is rendered on button click ReactJS
- replay a video inside a React-bootstrap Carousel
- Can i change a single child component in a loop without re-rendering the whole list (react hooks)
- Create an axios post with multiple inputs using React Hooks
- Is there some way to validate redux-form in a custom input?
- React Material UI DataGrid style MuiDataGrid-window within createMuiTheme or makeStyles / styled
- How to implement a delay timer that flip useState(true) to useState(false) in react js?
- Problem with Reducer that contains few different values
- position element dynamically after a render react js
- React and canvas reactivity
- How to deploy a create-react-app to a web host (ex. Siteground)?
- Resetting formik forms after changing user
- File Input doesn't store file information, just the name
- Display nth comment only when the nth value of an array is equal to true in react from firebase
- using setState with an array of objects
- React and Yii2 connection error - No 'Access-Control-Allow-Origin' header is present on the requested resource