Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

feat: add wrapper option to mountHook function #536

Merged
merged 3 commits into from
Nov 14, 2020
Merged

Conversation

bahmutov
Copy link
Contributor

Added wrapper similar to https://github.com/testing-library/react-hooks-testing-library/blob/master/docs/usage/advanced-hooks.md

import { mountHook } from 'cypress-react-unit-test'
// wrapper is optional, only if your hook requires
// something like a context provider
const wrapper = ({ children }) => <Provider store={store}>{children}</Provider>
mountHook(() => useCustomHook(), { wrapper })

@bahmutov bahmutov changed the title Wrap mount hook feat: add wrapper option to mountHook function Nov 13, 2020
@bahmutov bahmutov merged commit 22fd85f into main Nov 14, 2020
@bahmutov bahmutov deleted the wrap-mount-hook branch November 14, 2020 21:31
@bahmutov
Copy link
Contributor Author

🎉 This PR is included in version 4.17.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

let mountElement: any = testElement
if (options.wrapper) {
// what's the proper type? I don't even care anymore
// because types for React seem to be a mess

Choose a reason for hiding this comment

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

That's not true. React types are better than Vue, and may be better than Angular !

key: Math.random().toString(),
})

let mountElement: any = testElement

Choose a reason for hiding this comment

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

any => React.Element

@bahmutov
Copy link
Contributor Author

bahmutov commented Nov 14, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Question] Stubbing/Mocking redux hooks in mountHook
2 participants