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

suspenseFallback option is not supported #103

Open
michael-vasyliv opened this issue Apr 13, 2020 · 3 comments
Open

suspenseFallback option is not supported #103

michael-vasyliv opened this issue Apr 13, 2020 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@michael-vasyliv
Copy link

michael-vasyliv commented Apr 13, 2020

When writing a test to validate my component is rendered, I see the fallback value.
here is component

import { h } from 'preact';
import { memo, Suspense } from 'preact/compat';

const Container = memo(({ component }) => (
    <Suspense fallback='loading'>
        {h(component, {})}
    </Suspense>
))

export default Container;

here is test

import { shallow, mount } from 'enzyme';
import { h } from 'preact';
import Container from '../src/components/container';
import { lazy } from 'preact/compat';

const LazyComponent = lazy(() => import('../src/components/lazy-component'));

describe('Container', () => {

    it('renders the LazyComponent', () => {
        const wrapper = mount(<Container component={LazyComponent} />, { suspenseFallback: false });
        console.log(wrapper.debug());
        expect(wrapper.find(LazyComponent).length).toEqual(1);
    });
})

here is result of the console.log

    <Memo() component={[Function: u]}>
      <Component component={[Function: u]}>
        <d fallback="loading">
          <d />
          loading
        </d>
      </Component>
    </Memo()>

as you can see there is not any of LazyComponent only fallback
here is repo with code
https://github.com/michael-vasyliv/preact-project

similar issue in enzymejs/enzyme#2200

@robertknight robertknight changed the title lazy all time returns fallback suspenseFallback is not supported Apr 13, 2020
@robertknight robertknight changed the title suspenseFallback is not supported suspenseFallback option is not supported Apr 13, 2020
@robertknight
Copy link
Member

Thank-you for the report! The suspenseFallback option was added in Enzyme v3.10.0 and is currently not handled at all by the Preact adapter.

The suspenseFallback option is also only available for shallow rendering, so your example project won't work with React either as far as I can see.

In the interim, I would look for examples of how to test suspense components and fallbacks that don't rely on Enzyme features but instead just use the regular React API.

@robertknight robertknight added the help wanted Extra attention is needed label Apr 13, 2020
@ashleyyang0610
Copy link

Hey any update to the issue? We encounter the same problem that willing to test suspense component in the Preact project.

@robertknight
Copy link
Member

Hey any update to the issue?

No. Nothing has changed since my last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants