Skip to content

Conversation

kdquistanchala
Copy link
Contributor

This PR adds the toHaveProp() matcher for React Native

@kdquistanchala kdquistanchala self-assigned this Apr 2, 2025
@kdquistanchala kdquistanchala added the enhancement New feature or request label Apr 2, 2025
* @returns the assertion instance
*/
public toHaveProp(propName: string, value?: unknown): this {
const propValue: unknown = get(this.actual, `props.${propName}`, undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as for my understanding, why are we using uknown instead of undefined or any in here?

const invertedErrorMessage = value === undefined
? `Expected element ${this.toString()} NOT to have prop '${propName}'.`
: `Expected element ${this.toString()} NOT to have prop '${propName}' with value '${String(value)}'.`;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding to the error message something like: Verify the element properties?

@lopenchi lopenchi force-pushed the feat/native-to-contain-element branch 2 times, most recently from 4194055 to 392d9c6 Compare July 14, 2025 21:43
@lopenchi lopenchi force-pushed the feat/native-to-contain-element branch from 560250d to a560a05 Compare July 22, 2025 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants