Skip to content

Commit ff06c88

Browse files
committed
cast container type because of an type issue currently in testing-library
see: testing-library/react-testing-library#841 testing-library/dom-testing-library#834
1 parent 8978974 commit ff06c88

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

__tests__/index.test.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,18 @@ test('avoid unnecessary re-rendering', async () => {
291291
};
292292

293293
const timeout = 500;
294-
const { container, getByTestId } = render(
294+
const { container: containerElement, getByTestId } = render(
295295
<div>
296296
<ClickView recurseCount={3} />
297297
<ClickButtonAdd />
298298
<ClickButtonReset />
299299
</div>,
300300
);
301301

302+
// https://github.com/testing-library/react-testing-library/issues/841
303+
// https://github.com/testing-library/dom-testing-library/pull/834
304+
const container: HTMLElement = containerElement as HTMLElement;
305+
302306
// each element's renderer and effect should have been called once
303307
expect(getByTestId('render-clicks-3').textContent).toBe('clicks: 0');
304308
expect(getByTestId('render-clicks-2').textContent).toBe('clicks: 0');
@@ -447,14 +451,18 @@ test('avoid unnecessary re-rendering with just setters and state consumers', asy
447451
};
448452

449453
const timeout = 500;
450-
const { container, getByTestId } = render(
454+
const { container: containerElement, getByTestId } = render(
451455
<div>
452456
<ClickView recurseCount={3} />
453457
<ClickButtonAdd />
454458
<ClickButtonReset />
455459
</div>,
456460
);
457461

462+
// https://github.com/testing-library/react-testing-library/issues/841
463+
// https://github.com/testing-library/dom-testing-library/pull/834
464+
const container: HTMLElement = containerElement as HTMLElement;
465+
458466
// each element's renderer and effect should have been called once
459467
expect(getByTestId('render-clicks-3').textContent).toBe('clicks: 0');
460468
expect(getByTestId('render-clicks-2').textContent).toBe('clicks: 0');
@@ -611,7 +619,7 @@ test('update same state multiple times', async () => {
611619
};
612620

613621
const timeout = 500;
614-
const { container, getByTestId } = render(
622+
const { container: containerElement, getByTestId } = render(
615623
<div>
616624
<View id={1} />
617625
<IncA />
@@ -621,6 +629,10 @@ test('update same state multiple times', async () => {
621629
</div>,
622630
);
623631

632+
// https://github.com/testing-library/react-testing-library/issues/841
633+
// https://github.com/testing-library/dom-testing-library/pull/834
634+
const container: HTMLElement = containerElement as HTMLElement;
635+
624636
expect(getByTestId('inc-c').textContent).toBe('inc 10');
625637
expect(getByTestId('view-1').textContent).toBe('a: 1, b: 6, c: 11');
626638
expect(getByTestId('view-2').textContent).toBe('a: 1, b: 6, c: 11');

0 commit comments

Comments
 (0)