Skip to content
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

Shallow rendering with context provider #56

Open
jawadst opened this issue Dec 29, 2017 · 1 comment
Open

Shallow rendering with context provider #56

jawadst opened this issue Dec 29, 2017 · 1 comment

Comments

@jawadst
Copy link

jawadst commented Dec 29, 2017

I am using a provider component to add context to the components I am testing.

Example:

expect((
  <Provider store={store}>
    <Component />
  </Provider>
)).to.eql('');

In that case, I am required to do a non-shallow rendering/deep comparison with eql instead of equal. If I don't (and use equal), the rendered HTML that I get is <Component /> (which is to be expected).

That being said, what I am looking for here is doing a shallow rendering "two levels deep" where <Component /> gets rendered but not its children.

Is there any way to do that currently with preact-jsx-chai? Is there another way to provide the context without losing the ability to do shallow rendering?

@developit
Copy link
Owner

Hmm - not sure if there's a way to do that via preact-jsx-chai, though the underlying preact-render-to-string/jsx library has an option { renderRootComponent: true } that does exactly what you described..

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

No branches or pull requests

2 participants