Cross-platform Picker component with real i18n in tests #44
Conversation
Also add @react-native-community/picker to modules Jest must transpile
Previously it seemed to be included indirectly through subcomponents, which risks timing issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @AlanSl, looks good to me. I've just left a non-blocking comment about test's name convention.
}; | ||
|
||
describe('Picker Sheet', () => { | ||
it('value change calls onValueChange function', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I use the it()
function to define a test, I usually change the test's name/description to include it
as the subject of the sentence, to express the intention of the test (like in the e2e test: it('changes the app language')
).
Another option, would be leave the name/description as is, and use test()
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, consistency is good, I'll change it
* Install @react-native-community/picker, run expo update Also add @react-native-community/picker to modules Jest must transpile * Split cross-platform picker and language-selector * Use cross-platform picker in ListView * Update tests to use real i18n and web picker * Explicitly include i18n in app Previously it seemed to be included indirectly through subcomponents, which risks timing issues * Update e2e test, using same test ID as unit tests * Add readme note on using i18n in tests * Write test name as "It {does thing}" sentence * Also write other test name as "It {does thing}"
Picker
for the officially-endorsed @react-native-community/picker which is supported in Expo SDK 38changeLanguage
really do change the language (using i18n'scimode
, sot
continues to return the stable key in tests rather than the more-changable translated text)PickerSheet
a generic "did the function call" unit test and theLanguageSwitcher
a real test asserting that components withuseTranslation
do re-render on changes with a new languageTested on Web, simulated iOS and real Android. Fixed iOS view: