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.

Cypress broken by URL with special characters

See original GitHub issue

Current behavior

Our Phoenix app will redirect /vida to /vida/información-basica/empleo (notice the special character “ó”). That page then opens a websocket (same URL).

A test with cy.visit("/vida") in Cypress breaks. Same test after the route is changed to remove the accent on the “o” works.

With the accent “ó”, our server logs:

23:50:27.501 request_id=FsCF2BaXBlhl5zcAAAgJ [info] POST /end-to-end/login
%{account_id: 121}
23:50:27.513 request_id=FsCF2BaXBlhl5zcAAAgJ [info] Sent 200 in 11ms
23:50:27.765 request_id=FsCF2CZaEwCBqVMAAAhJ [info] GET /vida
23:50:27.776 request_id=FsCF2CZaEwCBqVMAAAhJ [info] Sent 302 in 10ms
23:50:27.994 request_id=FsCF2DQBvaBrqm8AABTF [info] GET /vida/información-basica/empleo
23:50:28.017 request_id=FsCF2DQBvaBrqm8AABTF [info] Sent 200 in 22ms
23:50:28.254 request_id=FsCF2EN3Zch76RgAABIH [info] GET /vida/informaci%C3%83%C2%B3n-basica/empleo

Without the accent, our server logs:

23:54:47.872 request_id=FsCGFLXrmkhSgwkAAH8C [info] POST /end-to-end/login
%{account_id: 123}
23:54:47.888 request_id=FsCGFLXrmkhSgwkAAH8C [info] Sent 200 in 16ms
23:54:48.434 request_id=FsCGFNdtukhKR34AAH9C [info] GET /vida
23:54:48.459 request_id=FsCGFNdtukhKR34AAH9C [info] Sent 302 in 24ms
23:54:49.175 request_id=FsCGFQOaTmBzlmsAAJzB [info] GET /vida/informacion-basica/empleo
23:54:49.228 request_id=FsCGFQOaTmBzlmsAAJzB [info] Sent 200 in 52ms
23:54:51.093 [info] CONNECTED TO Phoenix.LiveView.Socket in 59µs
  Transport: :websocket
  Serializer: Phoenix.Socket.V2.JSONSerializer
  Parameters: %{"_csrf_token" => "..., "_mounts" => "0", "vsn" => "2.0.0"}

On the Cypress side, only a single line appears:

# With the accent:
GET /vida/informaci%C3%83%C2%B3n-basica/empleo 404 300.388 ms - -
# Without the accent:
GET /vida/informacion-basica/empleo 200 5.114 ms - -

Screenshots of the requests from Chrome: Screen Shot 2021-12-13 at 11 51 52 PM Screen Shot 2021-12-13 at 11 57 11 PM

Desired behavior

Cypress should respect the encodings. Note that our app currently runs in production, with users having the usual browsers on desktop and mobile.

Test code to reproduce

cy.visit("/url-that-redirects-to-url-with-non-latin-characters"

Cypress Version

2.88.10

Other

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
einarperssoncommented, Mar 10, 2022

I just spent 3 hours today, and finally found this issue which explains my problem. I’ll use encodeURI now.

Please fix this, and consider adding a yellow warning box in the docs to cy.visit about this in the meantime.

Regards from Sweden (åäö)

1reaction
sainthkhcommented, Jan 2, 2022

You can bypass the problem by using encodeURI like below:

it('t', () => {
  cy.visit(encodeURI('https://seototo.net/한글-도메인-사용해도-될까-한글-도메인의-장단점-소/amp/'))
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Should contain failing in cypress when the match string has a ...
I just ran it locally for the string Name cannot accept special characters like < > | / : * ? " #;...
Read more >
Cypress-Fairbanks Independent School District / CFISD ...
Learn more about the proposed attendance boundary changes. The "Bringing Out the Best" character trait for the months of November & December is...
Read more >
Error Messages | Cypress Documentation
Cypress errors because after a command, the subject becomes 'fixed' to a specific element - since it can't retry commands, if the element...
Read more >
cypress-io/cypress - Gitter
CypressError : Special character sequence: '{"0c34-a556-84db":{"select ... why its break the test if the condition was not fulfilled?
Read more >
How To Find Broken Links Using Cypress [With Examples]
“If you are using Cypress to find broken links on your website, it is essential to note that Cypress changes its host URL...
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