Weird encoding issue inside javascript assets when Cypress runs
See original GitHub issueCurrent behavior:
When running a cypress test of an Angular 5 application which has been web-packed, a chunk is asynchronously loaded from the web server. This chunk is malformed (somewhere in the pipeline) consistently on the same byte of the same file each time. The problem does not manifest when you browse the site directly through Chrome, only during the Cypress test run.
Desired behavior:
The javascript files arrive at the browser intact and unmodified.
How to reproduce:
I’m not really sure on a reproduction.
Q: Is there a way I can bypass the cypress network stack for individual assets to try and identify if this is the cypress proxy or something else at play?
Here’s what I know so far…
The test throws the following error consistently in the same place of the test.
If you open the chunk file from a Chrome browser having run the application normally you see:
__WEBPACK_IMPORTED_MODULE_0__angular_core__["ɵand"]
However, when the error is thrown, the chunk contains the following:
__WEBPACK_IMPORTED_MODULE_0__angular_core__["��and"]
Full error and stack trace:
cypress_runner.js:138957 Console was cleared
cypress_runner.js:138954 Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0__angular_core__.��and is not a function
This error originated from your application code, not from Cypress.
When Cypress detects uncaught errors originating from your application it will automatically fail the current test.
This behavior is configurable, and you can choose to turn this off by listening to the 'uncaught:exception' event.
https://on.cypress.io/uncaught-exception-from-application
at View_Dropdown_8 (https://<url-redacted>/0.d44dcaa6cf578dfd34f1.chunk.js:3913:490)
at resolveDefinition (https://<url-redacted>/vendor.bundle.js?v=FtrhNBpDu18Mnhl7cHgNIXl06Fwzd5RdnAWtKahf5Qg:127750:17)
at Object.anchorDef (https://<url-redacted>/vendor.bundle.js?v=FtrhNBpDu18Mnhl7cHgNIXl06Fwzd5RdnAWtKahf5Qg:128019:55)
at View_Dropdown_0 (https://<url-redacted>/0.d44dcaa6cf578dfd34f1.chunk.js:3939:4669)
at resolveDefinition (https://<url-redacted>/vendor.bundle.js?v=FtrhNBpDu18Mnhl7cHgNIXl06Fwzd5RdnAWtKahf5Qg:127750:17)
at createViewNodes (https://<url-redacted>/vendor.bundle.js?v=FtrhNBpDu18Mnhl7cHgNIXl06Fwzd5RdnAWtKahf5Qg:131297:56)
at callViewAction (https://<url-redacted>/vendor.bundle.js?v=FtrhNBpDu18Mnhl7cHgNIXl06Fwzd5RdnAWtKahf5Qg:131768:13)
at execComponentViewsAction (https://<url-redacted>/vendor.bundle.js?v=FtrhNBpDu18Mnhl7cHgNIXl06Fwzd5RdnAWtKahf5Qg:131677:13)
at createViewNodes (https://<url-redacted>/vendor.bundle.js?v=FtrhNBpDu18Mnhl7cHgNIXl06Fwzd5RdnAWtKahf5Qg:131361:5)
at callViewAction (https://<url-redacted>/vendor.bundle.js?v=FtrhNBpDu18Mnhl7cHgNIXl06Fwzd5RdnAWtKahf5Qg:131768:13)
From previous event:
at run (https://<url-redacted>/__cypress/runner/cypress_runner.js:62383:15)
at Object.cy.(anonymous function) [as get] (https://<url-redacted>/__cypress/runner/cypress_runner.js:62603:11)
at Context.runnable.fn (https://<url-redacted>/__cypress/runner/cypress_runner.js:62734:20)
at callFn (https://<url-redacted>/__cypress/runner/cypress_runner.js:32354:21)
at Test.Runnable.run (https://<url-redacted>/__cypress/runner/cypress_runner.js:32347:7)
at https://<url-redacted>/__cypress/runner/cypress_runner.js:65627:28
at <anonymous>
From previous event:
at Object.onRunnableRun (https://<url-redacted>/__cypress/runner/cypress_runner.js:65626:20)
at $Cypress.action (https://<url-redacted>/__cypress/runner/cypress_runner.js:61088:51)
at Test.Runnable.run (https://<url-redacted>/__cypress/runner/cypress_runner.js:64766:20)
at Runner.runTest (https://<url-redacted>/__cypress/runner/cypress_runner.js:32817:10)
at https://<url-redacted>/__cypress/runner/cypress_runner.js:32923:12
at next (https://<url-redacted>/__cypress/runner/cypress_runner.js:32737:14)
at https://<url-redacted>/__cypress/runner/cypress_runner.js:32747:7
at next (https://<url-redacted>/__cypress/runner/cypress_runner.js:32679:14)
at https://<url-redacted>/__cypress/runner/cypress_runner.js:32715:5
at timeslice (https://<url-redacted>/__cypress/runner/cypress_runner.js:27956:27)
- Operating System: Windows 10 & Server 2012
- Cypress Version: 2.0.4
- Browser Version: Chrome 64 and Electron with Chrome 59 both exhibit this behaviour
Issue Analytics
- State:
- Created 6 years ago
- Comments:21 (12 by maintainers)
Top GitHub Comments
My mistake on the middle part. Looks like calling
setEncoding("utf8")
on the stream returned byzlib.createGunzip()
would solve the problem and let you still use a stream. https://github.com/nodejs/node/issues/21274#issuecomment-396416532This is probably a duplicate of: #1746