From ff06c888928144b80654a5b2c118a9eb5a87ef70 Mon Sep 17 00:00:00 2001 From: pabra Date: Sun, 13 Dec 2020 10:24:11 +0100 Subject: [PATCH] cast container type because of an type issue currently in testing-library see: https://github.com/testing-library/react-testing-library/issues/841 https://github.com/testing-library/dom-testing-library/pull/834 --- __tests__/index.test.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/__tests__/index.test.tsx b/__tests__/index.test.tsx index c9ad71f..dfbd37f 100644 --- a/__tests__/index.test.tsx +++ b/__tests__/index.test.tsx @@ -291,7 +291,7 @@ test('avoid unnecessary re-rendering', async () => { }; const timeout = 500; - const { container, getByTestId } = render( + const { container: containerElement, getByTestId } = render(
@@ -299,6 +299,10 @@ test('avoid unnecessary re-rendering', async () => {
, ); + // https://github.com/testing-library/react-testing-library/issues/841 + // https://github.com/testing-library/dom-testing-library/pull/834 + const container: HTMLElement = containerElement as HTMLElement; + // each element's renderer and effect should have been called once expect(getByTestId('render-clicks-3').textContent).toBe('clicks: 0'); expect(getByTestId('render-clicks-2').textContent).toBe('clicks: 0'); @@ -447,7 +451,7 @@ test('avoid unnecessary re-rendering with just setters and state consumers', asy }; const timeout = 500; - const { container, getByTestId } = render( + const { container: containerElement, getByTestId } = render(
@@ -455,6 +459,10 @@ test('avoid unnecessary re-rendering with just setters and state consumers', asy
, ); + // https://github.com/testing-library/react-testing-library/issues/841 + // https://github.com/testing-library/dom-testing-library/pull/834 + const container: HTMLElement = containerElement as HTMLElement; + // each element's renderer and effect should have been called once expect(getByTestId('render-clicks-3').textContent).toBe('clicks: 0'); expect(getByTestId('render-clicks-2').textContent).toBe('clicks: 0'); @@ -611,7 +619,7 @@ test('update same state multiple times', async () => { }; const timeout = 500; - const { container, getByTestId } = render( + const { container: containerElement, getByTestId } = render(
@@ -621,6 +629,10 @@ test('update same state multiple times', async () => {
, ); + // https://github.com/testing-library/react-testing-library/issues/841 + // https://github.com/testing-library/dom-testing-library/pull/834 + const container: HTMLElement = containerElement as HTMLElement; + expect(getByTestId('inc-c').textContent).toBe('inc 10'); expect(getByTestId('view-1').textContent).toBe('a: 1, b: 6, c: 11'); expect(getByTestId('view-2').textContent).toBe('a: 1, b: 6, c: 11');