nithinpp69/react-native-circular-progress-indicator

jest: Element type is invalid: expected a string

Opened this issue · 0 comments

When i run jest i get this error:

    Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

    Check the render method of `UploadingProgressIndicator`.

my code is as below:

import CircularProgress from 'react-native-circular-progress-indicator'

const progressPropTypes = {
  progress: PropTypes.number.isRequired,
  copy: PropTypes.objectOf(PropTypes.any).isRequired
}

const UploadingProgressIndicator = ({
  progress = 0,
  copy = { uploading: '' }
}) => (
  <>
    <CircularProgress
      value={progress * 100}
      radius={16}
      textColor={'transparent'}
      activeStrokeColor={COLORS.white}
      inActiveStrokeColor={COLORS.white}
      inActiveStrokeOpacity={0.5}
      activeStrokeWidth={6}
      inActiveStrokeWidth={6}
    />
    <Text style={styles.loadingText}>{copy.uploading}</Text>
  </>
)

my test

import MediaProgressOverlay from './MediaProgressOverlay'

describe('<MediaProgressOverlay />', () => {
  test('render component with empty states', () => {
    const { container } = render(
      <MediaProgressOverlay
        uploadingImages={{}}
        compressVideo={{}}
        image={{}}
        copy={{}}
      />
    )

    expect(container.child).toBeUndefined()
  })

however, when i import react-native-circular-progress-indicator in the test, the test pass

but I don't see why should I import the library in my test in this case?