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

fix(render): add default type for Queries parameter #871

Merged
merged 2 commits into from
Feb 2, 2021

Conversation

solufa
Copy link
Contributor

@solufa solufa commented Feb 2, 2021

What:
Fixed type definition

Why:

v11.2.3

import { render, fireEvent } from '@testing-library/react'

const { getByText } = render(<div />, options)
fireEvent.click(getByText('foobaz')) // no type error

v11.2.4

import { render, fireEvent } from '@testing-library/react'

const { getByText } = render(<div />, options)
fireEvent.click(getByText('foobaz')) // TS2345: Argument of type 'Error | HTMLElement | HTMLElement[] | Promise<HTMLElement[]> | Promise<HTMLElement> | null' is not assignable to parameter of type 'Element | Node | Window | Document'.

v11.2.4-fixed

import { render, queries, fireEvent } from '@testing-library/react'

const { getByText } = render<typeof queries>(<div />, options)
fireEvent.click(getByText('foobaz')) //  no type error

PR

import { render, fireEvent } from '@testing-library/react'

const { getByText } = render(<div />, options)
fireEvent.click(getByText('foobaz')) // no type error

How:
I added default type to render's first parameter

Checklist:

  • Documentation added to the
    docs site
  • Tests
  • Typescript definitions updated
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 2, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7f1008e:

Sandbox Source
React Configuration
react-testing-library-examples Configuration

@codecov
Copy link

codecov bot commented Feb 2, 2021

Codecov Report

Merging #871 (e5f08c3) into master (81c2de9) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #871   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          140       140           
  Branches        26        26           
=========================================
  Hits           140       140           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81c2de9...7f1008e. Read the comment docs.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you add a test to types/test.tsx? I guess you could just paste e the code that was previously working.

@solufa
Copy link
Contributor Author

solufa commented Feb 2, 2021

OK. Please wait while I add the test.

@eps1lon eps1lon changed the title fix(types): add default type to render's parameter fix(render): add default type for Queries parameter Feb 2, 2021
@eps1lon eps1lon merged commit 5576e6f into testing-library:master Feb 2, 2021
@eps1lon
Copy link
Member

eps1lon commented Feb 2, 2021

@solufa Awesome, thanks!

@eps1lon
Copy link
Member

eps1lon commented Feb 2, 2021

@all-contributors Add @solufa for bugs and code

@allcontributors
Copy link
Contributor

@eps1lon

I've put up a pull request to add @solufa! 🎉

@github-actions
Copy link

github-actions bot commented Feb 2, 2021

🎉 This PR is included in version 11.2.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants