I am trying to implement the first snapshot tests into an existing React-Native project that has been going for a year or two. I am facing quite a lot of issues.
Right now my test looks like this:
import React from 'react'
import renderer from 'react-test-renderer'
const ReactNative = require.requireActual('react-native')
const Avatar = require('../elements/Avatar')
jest.mock('react-native-device-info', () => 'Device-info')
jest.mock('react-redux', () => ({ connect: jest.fn }))
jest.mock('prop-types', () => ({
oneOf: jest.fn(),
oneOfType: jest.fn(),
shape: jest.fn(),
arrayOf: jest.fn(),
}))
jest.mock('react-native', () => ({
...ReactNative,
Dimensions: {
get: jest.fn().mockReturnValue({ width: 100, height: 100 }),
},
Platform: {
select: jest.fn().mockReturnValue('ios'),
},
}))
it('should render different Avatar sizes correctly', () => {
const tree = renderer
.create(<Avatar />)
.toJSON()
expect(tree).toMatchSnapshot()
})
Whenever I run the test I get this error.
Invariant Violation: "alignSelf" is not a valid style property.
StyleSheet unimplementedView: {
"alignSelf": "flex-start",
"borderColor": "red",
"borderWidth": 1
}
at invariant (node_modules/fbjs/lib/invariant.js:42:15)
at styleError (node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js:67:1)
at Function.validateStyleProp (node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js:35:1)
at Function.validateStyle (node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js:55:22)
at Object.create (node_modules/react-native/Libraries/StyleSheet/StyleSheet.js:226:22)
at Object.<anonymous> (node_modules/react-native/Libraries/Components/UnimplementedViews/UnimplementedView.js:40:23)
at Object.<anonymous> (node_modules/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js:13:16)
What could be causing "alignSelf not to be accepted as a style property, even though it is one?
Aucun commentaire:
Enregistrer un commentaire