Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions packages/react-devtools-shared/src/__tests__/store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1817,13 +1817,8 @@ describe('Store', () => {
jest.runOnlyPendingTimers();
}

// Gross abstraction around pending passive warning/error delay.
function flushPendingPassiveErrorAndWarningCounts() {
jest.advanceTimersByTime(1000);
}

// @reactVersion >= 18.0
it('are counted (after a delay)', () => {
it('are counted (after no delay)', () => {
function Example() {
React.useEffect(() => {
console.error('test-only: passive error');
Expand All @@ -1838,13 +1833,6 @@ describe('Store', () => {
}, false);
});
flushPendingBridgeOperations();
expect(store).toMatchInlineSnapshot(`
[root]
<Example>
`);

// After a delay, passive effects should be committed as well
act(flushPendingPassiveErrorAndWarningCounts, false);
expect(store).toMatchInlineSnapshot(`
✕ 1, ⚠ 1
[root]
Expand Down Expand Up @@ -1879,8 +1867,9 @@ describe('Store', () => {
}, false);
flushPendingBridgeOperations();
expect(store).toMatchInlineSnapshot(`
✕ 1, ⚠ 1
[root]
<Example>
<Example> ✕⚠
`);

// Before warnings and errors have flushed, flush another commit.
Expand All @@ -1894,22 +1883,13 @@ describe('Store', () => {
}, false);
flushPendingBridgeOperations();
expect(store).toMatchInlineSnapshot(`
1, ⚠ 1
2, ⚠ 2
[root]
<Example> ✕⚠
<Noop>
`);
});

// After a delay, passive effects should be committed as well
act(flushPendingPassiveErrorAndWarningCounts, false);
expect(store).toMatchInlineSnapshot(`
✕ 2, ⚠ 2
[root]
<Example> ✕⚠
<Noop>
`);

act(() => unmount());
expect(store).toMatchInlineSnapshot(``);
});
Expand Down
Loading
Loading