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: log ignored selectors correctly on error #1141

Merged
merged 3 commits into from
Aug 9, 2022

Conversation

robin-drexler
Copy link
Contributor

@robin-drexler robin-drexler commented Jun 22, 2022

What:

default getElementError implementation always logged that script and style are being ignored even when the default has been overridden with the defaultIgnore option.

It now logs the correct selector.
Since the selector could be any css selector, we can't just print <script /> etc. Instead we just print the selector as is.

Checklist:

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 22, 2022

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 a203ff0:

Sandbox Source
react-testing-library-examples Configuration

})

afterEach(() => {
configure(originalConfig)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ensure tests don't rely on previous tests changing the config in a certain way.

@codecov
Copy link

codecov bot commented Jun 22, 2022

Codecov Report

Merging #1141 (a203ff0) into main (b7aaf18) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main     #1141   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines          990       990           
  Branches       322       322           
=========================================
  Hits           990       990           
Flag Coverage Δ
node-12 100.00% <ø> (ø)
node-14 100.00% <ø> (ø)
node-16 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/config.ts 100.00% <ø> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@@ -1092,6 +1102,19 @@ test('the default value for `ignore` can be configured', () => {
expect(noStyle[1].tagName).toBe('DIV')
})

test('the default value for `ignore` is used in errors', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New test that proves that overriding defaultIgnore produces a new error message

@robin-drexler robin-drexler marked this pull request as ready for review June 22, 2022 02:03
@@ -194,14 +194,14 @@ test('when a promise is returned, if that is not resolved within the timeout, th
await sleep(5)

expect((await waitForError).message).toMatchInlineSnapshot(`
Timed out in waitFor.

Ignored nodes: comments, <script />, <style />
Copy link
Member

Choose a reason for hiding this comment

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

Can we keep the original formatting? "comments, scripts, style" looks like they all refer to the same thing while "scripts, style" specifically refers to elements.

Copy link
Member

Choose a reason for hiding this comment

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

Should be fine. Alternative is another .split().map().join() which is probably too expensive.

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!

@eps1lon eps1lon merged commit d50a967 into testing-library:main Aug 9, 2022
@eps1lon
Copy link
Member

eps1lon commented Aug 9, 2022

@all-contributors add @robin-drexler for code

@allcontributors
Copy link
Contributor

@eps1lon

@robin-drexler already contributed before to code

@github-actions
Copy link

github-actions bot commented Aug 9, 2022

🎉 This PR is included in version 8.17.1 🎉

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