mdbootstrap / mdb-angular-ui-kit

Angular 18 & Bootstrap 5 & Material Design UI KIT
https://mdbootstrap.com/docs/angular/
Other
1.12k stars 280 forks source link

Avoid doing setTimeout(undefined, 0) #97

Closed karel1980 closed 5 years ago

karel1980 commented 5 years ago

Expected behavior

When simulating keyboard input with cy.get('#input').type('blah') I get an error from Cypress because mdbootstrap calls setTimeout with 'undefined' as first argument:

https://github.com/mdbootstrap/Angular-Bootstrap-with-Material-Design/blob/6.2.2/src/angular-bootstrap-md/inputs/mdb-input.directive.ts#L290

Chrome silently ignores setTimeout(undefined, ...) but cypress wraps the 'setTimeout' function and gives an error when it is being called with first argument 'undefined'.

Actual behavior

My cypress tests should not fail 😉 The offending code is in 'delayedResize': https://github.com/mdbootstrap/Angular-Bootstrap-with-Material-Design/blob/6.2.2/src/angular-bootstrap-md/inputs/mdb-input.directive.ts#L290

Your working environment and MDB version information

6.2.2

Resources (screenshots, code snippets etc.)

delayedResize() { setTimeout(this.resize(), 0); }

should probably be replaced with delayedResize() { setTimeout(() => this.resize(), 0); }

There are a bunch of places (oncut, onpaste, ondrop, ...) where delayedResize is wrapped again with a setTimeout(); After replacing the delayedResize implementation there is probably no more reason for the additional wrapping.

karel1980 commented 5 years ago

Note: the error started showing up in cypress 3.1.1 (not tagged yet), somewhere in here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/timers.js#L25

Cypress 3.1.1 issue: https://github.com/cypress-io/cypress/issues/2719

Bloodcast69 commented 5 years ago

@karel1980

Thanks for your report! We'll take care of this.

Best Regards, Damian