question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird encoding issue inside javascript assets when Cypress runs

See original GitHub issue

Current 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:closed
  • Created 6 years ago
  • Comments:21 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
zbjornsoncommented, Jun 11, 2018

My mistake on the middle part. Looks like calling setEncoding("utf8") on the stream returned by zlib.createGunzip() would solve the problem and let you still use a stream. https://github.com/nodejs/node/issues/21274#issuecomment-396416532

0reactions
flotwigcommented, Jul 12, 2019

This is probably a duplicate of: #1746

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog - Cypress Documentation
Fixed an issue in cy.readFile() where the command would not retry or provide a meaningful error message if null encoding was used and...
Read more >
cypress runner ignoring charset="windows-1252" html tag
I'm testing a page which is windows-1252 encoded, it has the following meta tags in the html ...
Read more >
cypress-io/cypress - Gitter
Hi guys, I setup cypress with Teamcity CI. Everything works great, but I don't see in the build log the full verbose log...
Read more >
Don't (yes, don't!) worry about “garbled” characte...
Don't (yes, don't!) worry about “garbled” characters when opening JS files directly in your browser. Being paranoid about encoding — URL  ...
Read more >
multiple-cucumber-html-reporter - npm
Since cucumber-js 3.x the AfterFeatures hook is not supported anymore. To use Multiple Cucumber HTML Reporter it must be run in a separate ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found