Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: error in the baseElement typings #1004

Closed
dshuvalov opened this issue Dec 15, 2021 · 1 comment · Fixed by #1023
Closed

types: error in the baseElement typings #1004

dshuvalov opened this issue Dec 15, 2021 · 1 comment · Fixed by #1023
Labels
bug Something isn't working TypeScript Related to TypeScript. Note: only certain maintainers handle TypeScript labeled issues.

Comments

@dshuvalov
Copy link

  • @testing-library/react version: 12.1.2
  • Testing Framework and version: [email protected]
  • DOM Environment: jsdom

Relevant code or config:

it(`SHOULD open modal window WHEN user click on show button`, () => {
    const { baseElement } = render(<ControlledModalExample />)
    expect(screen.queryByTestId(dataTestId)).toBeNull()
    expect(baseElement.style.getPropertyValue('overflow')).toBe('')
    fireEvent.click(screen.getByText('Show'))
    const modal = screen.getByTestId(dataTestId)
    expect(modal).toBeDefined()
    expect(baseElement.style.getPropertyValue('overflow')).toBe('hidden')
  })

What you did:

I test the modal component. When a modal has appeared, it should block the body and prevent the user's scroll behavior.

What happened:

After upgrading to @testing-library/react up to 12.1.2 from 11.1.0, I noticed that typing for the baseElement was changed in the 11.12.5.
And I received such error:
Property 'style' does not exist on type 'Element'.

Reproduction:

Try to get some HTML attributes from the baseElement

Problem description:

Previously render returned baseElement as HTMLElement, but now it returns it as Element.

Suggested solution:

Provide examples in the documentation or make flexible types

@maximvl
Copy link

maximvl commented Jan 24, 2022

I can confirm having the same issue with upgrade to 12.1.2

@eps1lon eps1lon added bug Something isn't working TypeScript Related to TypeScript. Note: only certain maintainers handle TypeScript labeled issues. labels Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working TypeScript Related to TypeScript. Note: only certain maintainers handle TypeScript labeled issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants