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

test: Fail on unexpected console.warn and console.error #1139

Merged
merged 1 commit into from
Dec 6, 2022

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Oct 8, 2022

What:

Fail tests on console.error and console.warn calls that are not asserted (i.e. some spy intercepts them).
Also adds dedicated toWarnDev and toErrorDev matchers (see changed tests).
That help surfacing the intended errors better in tests.

Why:

Otherwise we might add tests that include "missign act" warnings which this library is trying to avoid (e.g. in #1137 the added test would all "pass" without any change to the implementation).

How:

Copy (and adjust) the pattern facebook/react uses.

Checklist:

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 8, 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 53f7fdc:

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

@codecov
Copy link

codecov bot commented Oct 8, 2022

Codecov Report

Merging #1139 (53f7fdc) into main (185e314) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main     #1139   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          181       181           
  Branches        36        36           
=========================================
  Hits           181       181           
Flag Coverage Δ
experimental 100.00% <ø> (ø)
latest 100.00% <ø> (ø)
next 100.00% <ø> (ø)

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

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@eps1lon eps1lon merged commit 801ad37 into testing-library:main Dec 6, 2022
@eps1lon eps1lon deleted the test/fail-on-warnings branch December 6, 2022 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants