Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: win.Event is not a constructor when entering text #5778

Closed
ShaminKarim opened this issue Nov 22, 2019 · 5 comments
Closed

TypeError: win.Event is not a constructor when entering text #5778

ShaminKarim opened this issue Nov 22, 2019 · 5 comments

Comments

@ShaminKarim
Copy link

ShaminKarim commented Nov 22, 2019

Current behavior:

Whenever I try to enter text during my test run, using .type, I come across a "TypeError: win.Event is not a constructor" error.

image

Desired behavior:

Enter the desired text when running the script.

Steps to reproduce: (app code and test code)

  1. Create a normal Cypress test.
  2. Use .type in order to have text inputted into text box.

image

Versions

Cypress 3.6.1

@rlaneve
Copy link

rlaneve commented Nov 26, 2019

@ShaminKarim We had a similar issue testing one of our apps. In our case, it was our app causing the issue, as we had some old code which declared an Event hash globally, which trashed the browser's built-in Event function. We stumbled upon it once we confirmed that the out-of-the-box sample tests in Cypress had no issue with the type() function; the issue only existed when our app was being tested.

Might be worth checking in your app. Simple test is to load up your app in Chrome, open the Dev Tools, and use the console to spit out window.Event. If it's anything other than a function, you have the same problem.

(Cypress dependency on the window.Event function was, I believe, introduced in v3.5.0, via this PR: #4870).

@jennifer-shehane
Copy link
Member

@rlaneve Thanks for the detailed response. This error message is less than ideal regardless of if the Application is overwriting event, but this would be helpful in recreating if that is the case.

@ShaminKarim Could you click on the yellow error in the Command Log with DevTools open and paste of screenshot of where the stack of the error is coming from? Thanks!

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Nov 27, 2019
@heloisam
Copy link

heloisam commented Jan 23, 2020

Hey!
I had the same problem today in v.3.8.2.
The solution was to downgrade to v.3.4.1.

Any news for the fix?

@ValentinK00
Copy link

ValentinK00 commented Jun 3, 2020

Hi, got the same problem in versions 3.5.0 and higher. Hope you will fix this problem soon. I was reading the comment higher and can attach the screenshot of errors in console, hope it'll help you.

image

@sainthkh
Copy link
Contributor

It's impossible to fix this problem without the problematic html example.

It might be because the program has overridden win.Event in JS files.

If someone meets the similar problem, please share with us the html file or app.

@sainthkh sainthkh closed this as completed Apr 2, 2021
@jennifer-shehane jennifer-shehane removed the stage: needs investigating Someone from Cypress needs to look at this label May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants