mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #5709 from overleaf/ae-fail-prop-types-tests
Format error messages for test failure GitOrigin-RevId: 74da66d9da31939755162a91f5adf4f8122f06f6
This commit is contained in:
parent
642764fccf
commit
c73894e56b
3 changed files with 16 additions and 3 deletions
|
@ -18,6 +18,9 @@ describe('<ToolbarHeader />', function () {
|
|||
togglePdfView: () => {},
|
||||
hasPublishPermissions: true,
|
||||
trackChangesVisible: true,
|
||||
handleChangeLayout: () => {},
|
||||
pdfLayout: '',
|
||||
view: '',
|
||||
}
|
||||
|
||||
describe('cobranding logo', function () {
|
||||
|
|
|
@ -76,7 +76,13 @@ describe('<OutlinePane />', function () {
|
|||
})
|
||||
|
||||
it('expand outline and use local storage', function () {
|
||||
global.localStorage.getItem.returns(false)
|
||||
global.localStorage.getItem.callsFake(key => {
|
||||
if (key.startsWith('file_outline.expanded.')) {
|
||||
return false
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
||||
const outline = [
|
||||
{
|
||||
title: 'Section',
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { format } from 'util'
|
||||
|
||||
/**
|
||||
* Make tests fail when prop-types are incorrect.
|
||||
*
|
||||
|
@ -14,10 +16,12 @@ before(function () {
|
|||
// Ensure we still log the error
|
||||
originalConsoleError(message, ...args)
|
||||
|
||||
const formattedMessage = format(message, ...args)
|
||||
|
||||
// Check if the error is from prop-types
|
||||
if (/Failed (prop|data) type/.test(message)) {
|
||||
if (/Failed (prop|data) type/.test(formattedMessage)) {
|
||||
// Throw an error, causing the test to fail
|
||||
throw new Error(message)
|
||||
throw new Error(formattedMessage)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue