File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ class ResizeObserverMock {
2+ constructor ( callback ) {
3+ this . callback = callback ;
4+ this . elements = new Set ( ) ;
5+ this . handleResize = this . handleResize . bind ( this ) ;
6+ }
7+
8+ observe ( element ) {
9+ this . elements . add ( element ) ;
10+ this . trigger ( ) ;
11+ window . addEventListener ( 'resize' , this . handleResize ) ;
12+ }
13+
14+ unobserve ( element ) {
15+ this . elements . delete ( element ) ;
16+ }
17+
18+ disconnect ( ) {
19+ this . elements . clear ( ) ;
20+ window . removeEventListener ( 'resize' , this . handleResize ) ;
21+ }
22+
23+ handleResize ( ) {
24+ this . trigger ( ) ;
25+ }
26+
27+ trigger ( ) {
28+ if ( this . elements . size == 0 ) return ;
29+
30+ const entries = Array . from ( this . elements ) . map ( e => ( {
31+ target : e ,
32+ contentRect : e . getBoundingClientRect ( ) ,
33+ } ) ) ;
34+
35+ requestAnimationFrame ( ( ) => {
36+ this . callback ( entries , this ) ;
37+ } ) ;
38+ }
39+ }
40+
41+ export default ResizeObserverMock ;
Original file line number Diff line number Diff line change 33 * See https://github.com/cypress-io/cypress/issues/20341
44 * See https://github.com/cypress-io/cypress/issues/29277
55 */
6- Cypress . on ( 'uncaught:exception' , err => {
7- if (
8- err . message . includes (
9- 'ResizeObserver loop completed with undelivered notifications'
10- )
11- ) {
12- return false ;
13- }
6+
7+ import ResizeObserverMock from './ResizeObserverMock' ;
8+
9+ Cypress . on ( 'window:before:load' , win => {
10+ win . ResizeObserver = ResizeObserverMock ;
1411} ) ;
Original file line number Diff line number Diff line change 11{
22 "extends" : " ../tsconfig.json" ,
33 "compilerOptions" : {
4- "rootDir" : " e2e"
4+ "rootDir" : " ." ,
5+ "noEmit" : true
56 },
6- "types" : [" cypress" , " node" ]
7- }
7+ "types" : [
8+ " cypress" ,
9+ " node"
10+ ],
11+ "include" : [
12+ " **/*.ts" ,
13+ " **/*.js" ,
14+ " cypress.config.js"
15+ ]
16+ }
You can’t perform that action at this time.
0 commit comments