mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #3308 from overleaf/revert-3278-as-prop-type-test-fail
Revert "Make prop-type errors fail the frontend tests" GitOrigin-RevId: 903fba2a6f22d392ba748ff334db0ddbc63ac896
This commit is contained in:
parent
224c5a0f23
commit
85d37f8990
1 changed files with 0 additions and 28 deletions
|
@ -1,28 +0,0 @@
|
|||
/**
|
||||
* Make tests fail when prop-types are incorrect.
|
||||
*
|
||||
* React's prop-types library logs an console.error when the types are
|
||||
* incorrect. Since this error is only in the console, tests that fail the type-
|
||||
* check will still pass.
|
||||
*
|
||||
* To ensure that type-checking is tested, monkey-patch the global console.error
|
||||
* to fail the tests when prop-types errors.
|
||||
*/
|
||||
const originalConsoleError = global.console.error
|
||||
before(function() {
|
||||
global.console.error = (message, ...args) => {
|
||||
// Ensure we still log the error
|
||||
originalConsoleError(message, ...args)
|
||||
|
||||
// Check if the error is from prop-types
|
||||
if (/Failed prop type/.test(message)) {
|
||||
// Throw an error, causing the test to fail
|
||||
throw new Error(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Restore the original method
|
||||
after(function() {
|
||||
global.console.error = originalConsoleError
|
||||
})
|
Loading…
Reference in a new issue