From 669b7fc1a21114511a1ed299df64f032f5ea7113 Mon Sep 17 00:00:00 2001 From: Xavier FACQ Date: Thu, 21 Sep 2023 21:39:01 +0200 Subject: [PATCH] Fix a pb with snapshots due to rendering animation (Highcharts) --- src/Graph/__tests__/BarChart.test.tsx | 63 +++++++++++++++------------ 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/Graph/__tests__/BarChart.test.tsx b/src/Graph/__tests__/BarChart.test.tsx index 2549937..a18db04 100644 --- a/src/Graph/__tests__/BarChart.test.tsx +++ b/src/Graph/__tests__/BarChart.test.tsx @@ -1,44 +1,51 @@ import React from 'react'; import { act, render } from '@testing-library/react'; -import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { afterAll, beforeAll, describe, expect, test } from 'vitest' import BarChart from '../BarChart' import Highcharts from 'highcharts' +// NOTE: Use a delay to avoid diff with rendering animation +// https://github.com/highcharts/highcharts/issues/14328 + +const delay = 2000; + const mock_data = { - "jdk8u302-b08": 3238608, - "jdk8u302-b08.1": 513472, - "jdk8u312-b07": 5815865, - "jdk8u322-b06": 4010319, - "jdk8u332-b09": 6751030, - "jdk8u342-b07": 629406, - "jdk8u342-b07.1": 61770, - "jdk8u345-b01": 3035189, - "jdk8u352-b08": 2791698, - "jdk8u362-b09": 3866298, - "jdk8u372-b07": 3210329, - "jdk8u382-b05": 1929984 + "jdk8u302-b08": 3238608, + "jdk8u302-b08.1": 513472, + "jdk8u312-b07": 5815865, + "jdk8u322-b06": 4010319, + "jdk8u332-b09": 6751030, + "jdk8u342-b07": 629406, + "jdk8u342-b07.1": 61770, + "jdk8u345-b01": 3035189, + "jdk8u352-b08": 2791698, + "jdk8u362-b09": 3866298, + "jdk8u372-b07": 3210329, + "jdk8u382-b05": 1929984 } beforeAll(async () => { - Highcharts.useSerialIds(true); + Highcharts.useSerialIds(true); }) afterAll(async () => { - Highcharts.useSerialIds(false); + Highcharts.useSerialIds(false); }) describe('BarChart component', () => { - test('renders correctly', async() => { - let container; - await act(async () => { - ({ container } = render( - - )); - }); - - expect(container).toMatchSnapshot(); - }); + test('renders correctly', async () => { + let container; + + await act(async () => { + ({ container } = render( + + )); + setTimeout(() => { }, delay) + }); + + expect(container).toMatchSnapshot(); + }); });