-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add support for passing context #49
Comments
I think this would be a great addition! The only remaining question is what the right API is. I propose that we add a second argument to
const context = { router: mockReactRouter() };
const wrapper = shallow(<MyComponent />, { context });
// ... cc @ljharb @goatslacker thoughts? |
That is the same API, |
@blainekasten to be clear, I'm recommending that on object hash with a |
My bad. Why that approach? What other keys would be used and why?
|
My thinking is that it allows other "options" be passed in as well in the future, rather than just having a bunch of arguments at random slots of the function signature. One such thing we discussed internally was the ability to have an option for const wrapper = mount(<Foo />, { attach: true }); Which could come in handy if you're wanting to test a component that uses DOM api's such as |
@laurakelly context support is now available on enzyme v1.2.0 |
@lelandrichardson Great, thank you! I'll try it out |
@lelandrichardson well, it looks like |
@lelandrichardson How does one mock |
@bscherminator what environment are you using
|
I have a component in my app that has a router passed to it via context:
const contextTypes = { router: React.PropTypes.func.isRequired, };
Reagent tests currently do not support passing in a context and will throw this error:
It would be great to be able to pass context into
shallow
.The text was updated successfully, but these errors were encountered: