简体   繁体   中英

React native testing with Jest using styled components

Getting the following error: TypeError: _styledComponents.default.View is not a function Using styles as code from below:

const LoadingWrap = styled.View`
  background-color: ${(props) => props.buttonColor};
  margin: 10px auto;
  padding: 15px;
  width: ${(props) => (props.small ? '100px' : '90%')};
  flex-direction: row;
  justify-content: center;
  align-items: center;
  border-radius: 80px;
  elevation: 3;
`;

I think you need to install and import 'jest-styled-components'; into your test file when using styled-components.

Some docs here: https://github.com/styled-components/jest-styled-components#jest-styled-components that you might find useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM