Before this change, NativeTestEvent.validTargets was an array of component names. Now it is an array of actual React Native components.
In addition, this diff fixes a bug in event tests where a describe() instead of a test() was being used, so the tests for every supported (component, event) pair were not being run (or were not being reported by the test runner).
Why:
I ran into a possible bug, when writing tests within an Expo project and using the "jest-expo" preset. I tried to fireEvent on a Switch element, but the handler for the event was never called. Digging in, I realized that my Switch's element.type was not the string "Switch"; it was the React Native Switch component class, which made me think that the assumption that element.type should be a string in validTargets is wrong.
What:
Before this change,
NativeTestEvent.validTargets
was an array of component names. Now it is an array of actual React Native components.In addition, this diff fixes a bug in event tests where a
describe()
instead of atest()
was being used, so the tests for every supported (component, event) pair were not being run (or were not being reported by the test runner).Why:
I ran into a possible bug, when writing tests within an Expo project and using the "jest-expo" preset. I tried to
fireEvent
on a Switch element, but the handler for the event was never called. Digging in, I realized that my Switch'selement.type
was not the string "Switch"; it was the React Native Switch component class, which made me think that the assumption thatelement.type
should be a string invalidTargets
is wrong.Checklist: