Skip to content

feat(native): Add toHaveProp #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: feat/native-to-contain-element
Choose a base branch
from

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?

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