feat(native): add toHaveStyle#152
Open
ACR1209 wants to merge 6 commits intofeat/native-to-have-propfrom
Open
Conversation
suany0805
reviewed
Jul 10, 2025
suany0805
reviewed
Jul 23, 2025
suany0805
reviewed
Oct 6, 2025
Contributor
suany0805
left a comment
There was a problem hiding this comment.
LGTM! Just left a question :)
| * @example | ||
| * ``` | ||
| * expect(element).toHaveStyle({ backgroundColor: "red" }); | ||
| * expect(element).toHaveStyle([{ backgroundColor: "red" }]); |
Contributor
There was a problem hiding this comment.
why are we allowing an array of styling objects in here? 🤔
Author
There was a problem hiding this comment.
This is because you can have an array of styles on React Native for styling 😄
Snippet from the Style docs of supported style prop values
import React from 'react';
import {StyleSheet, Text, View} from 'react-native';
const LotsOfStyles = () => {
return (
<View style={styles.container}>
<Text style={styles.red}>just red</Text>
<Text style={styles.bigBlue}>just bigBlue</Text>
<Text style={[styles.bigBlue, styles.red]}>bigBlue, then red</Text>
<Text style={[styles.red, styles.bigBlue]}>red, then bigBlue</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
marginTop: 50,
},
bigBlue: {
color: 'blue',
fontWeight: 'bold',
fontSize: 30,
},
red: {
color: 'red',
},
});
export default LotsOfStyles;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds the
toHaveStylematcher for the React Native module