Fix issues caused by applications which expect performance.getEntries, performance.getEntriesByName, and performance.getEntriesByType to return arrays (such as Facebook SDK - downstream issue: cypress-io/cypress#3625)
Right now, lolex clobbers these with () => undefined. Just using () => [] instead would fix this.
Purpose (TL;DR)
Fix issues caused by applications which expect
performance.getEntries
,performance.getEntriesByName
, andperformance.getEntriesByType
to return arrays (such as Facebook SDK - downstream issue: cypress-io/cypress#3625)Right now, lolex clobbers these with
() => undefined
. Just using() => []
instead would fix this.Background (Problem in detail)
MDN page for Performance functions: https://developer.mozilla.org/en-US/docs/Web/API/Performance
Only 5 have non-undefined return types. The other 2 (besides
getEntries.*
) are:now()
- already done by lolextoJSON()
- not handled, not sure if there's a good way to mock this valueSolution
Just have those 3 methods return
[]
whenlolex.install()
is called, instead ofundefined