Skip to content

Commit

Permalink
Failing test for false positive warning
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Feb 11, 2019
1 parent e15542e commit 63e371c
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1366,4 +1366,35 @@ describe('ReactHooks', () => {
),
).toThrow('Hello');
});

// Regression test for https://github.com/facebook/react/issues/14790
fit('does not fire a false positive warning when suspending', async () => {
const {Suspense, useState, useRef} = React;

let wasSuspended = false;
function trySuspend() {
if (!wasSuspended) {
throw new Promise(resolve => {
wasSuspended = true;
resolve();
});
}
}

function Child() {
React.useState();
trySuspend();
return 'hello';
}

const Wrapper = React.memo(Child);
const root = ReactTestRenderer.create(
<Suspense fallback="loading">
<Wrapper />
</Suspense>,
);
expect(root).toMatchRenderedOutput('loading');
await Promise.resolve();
expect(root).toMatchRenderedOutput('hello');
});
});

0 comments on commit 63e371c

Please sign in to comment.