mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-09 10:25:50 +00:00
Merge pull request #3311 from overleaf/jel-button-test
Add required prop to button test GitOrigin-RevId: c653b0429e4b9e9921e3e913fc0ff5ea445615a3
This commit is contained in:
parent
edd43228a1
commit
6a837ce457
2 changed files with 31 additions and 0 deletions
|
@ -96,6 +96,9 @@ describe('<PreviewRecompileButton />', function() {
|
|||
})
|
||||
|
||||
function renderPreviewRecompileButton(compilerState = {}) {
|
||||
if (!compilerState.logEntries) {
|
||||
compilerState.logEntries = {}
|
||||
}
|
||||
render(
|
||||
<PreviewRecompileButton
|
||||
compilerState={{
|
||||
|
|
28
services/web/test/frontend/prop-types.test.js
Normal file
28
services/web/test/frontend/prop-types.test.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* 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…
Add table
Reference in a new issue