'Warning: An update to ForwardRef(StickyScrollBar) inside a test was not wrapped in act(...)

I have come across this error when attempting to run my test cases. I have tried the solution suggested here to no luck.

Here is my test code:

import React from 'react'
import { act, render } from '@testing-library/react'
import App from './App'

describe('Renders App Component', () => {
  let getByTestId
  beforeEach(() => {
    const component = render(<App />)
    getByTestId = component.getByTestId
  })

  it('Renders Header Caption', () => {
    const header = getByTestId('header-caption')

    expect(header.textContent).toBe('Data Dashboard')
  })
})

Here is the error that I'm seeing: enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source