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

prefer-screen-queries: Don't warn if using the baseElement option #188

Closed
kentcdodds opened this issue Jun 23, 2020 · 7 comments · Fixed by #201
Closed

prefer-screen-queries: Don't warn if using the baseElement option #188

kentcdodds opened this issue Jun 23, 2020 · 7 comments · Fixed by #201
Assignees
Labels
enhancement New feature or request released

Comments

@kentcdodds
Copy link
Member

This should be acceptable (from the React Testing Library tests):

test('baseElement isolates trees from one another', () => {
  const {getByText: getByTextInA} = render(<div>Jekyll</div>, {
    baseElement: treeA,
  })
  const {getByText: getByTextInB} = render(<div>Hyde</div>, {
    baseElement: treeB,
  })

  expect(() => getByTextInA('Jekyll')).not.toThrow(
    'Unable to find an element with the text: Jekyll.',
  )
  expect(() => getByTextInB('Jekyll')).toThrow(
    'Unable to find an element with the text: Jekyll.',
  )

  expect(() => getByTextInA('Hyde')).toThrow(
    'Unable to find an element with the text: Hyde.',
  )
  expect(() => getByTextInB('Hyde')).not.toThrow(
    'Unable to find an element with the text: Hyde.',
  )
})
@nickserv nickserv added the enhancement New feature or request label Jun 23, 2020
@Belco90
Copy link
Member

Belco90 commented Jun 24, 2020

So the use case is basically several renders within same test right? Just trying to find a pattern to apply to the rule.

@timdeschryver
Copy link
Member

I think we should take baseElement into account in some of the rules and disable them? (mostly the rules that are working with screen).

@thomaslombart
Copy link
Collaborator

thomaslombart commented Jul 20, 2020

If I get it right, we need to make it so prefer-screen-queries doesn't fire if the render function has a container or baseElement option. Is that correct?

@kentcdodds
Copy link
Member Author

That is correct

@gndelia
Copy link
Collaborator

gndelia commented Jul 20, 2020

I think I can take this one if no one else is taking it

@kentcdodds
Copy link
Member Author

Sounds awesome 🤘

@Belco90
Copy link
Member

Belco90 commented Jul 29, 2020

🎉 This issue has been resolved in version 3.4.0 🎉

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
enhancement New feature or request released
Projects
None yet
6 participants