0

I'm testing a page which is windows-1252 encoded, it has the following meta tags in the html:

<html>
<head>
  <title>Meta-SSC</title>
  <meta http-equiv="Content-Type" content="text/html">
  <meta charset="windows-1252">

But cypress runner won't catch it, and can't correctly display characters like á, é, etc., like this:

cypress runner ignoring windows 1252 charset html meta tag

My test are failing because of this.

On the other hand, when testing it on chrome (Version 72.0.3626.121 Official Build 32-bit running on windows 10) or firefox (65.0.2 64bits) it works ok:

enter image description here

Any idea how could I troubleshoot it?


Found this issue at Cypress' github that might be related.

opensas
  • 60,462
  • 79
  • 252
  • 386

1 Answers1

0

It is indeed a known issue

this is the workaround I developed:

Cypress.Commands.add('containsLike', {
  prevSubject: true
}, (subject, search, chars) => {

  chars = chars || 'áéíóúñÁÉÍÓÚÑ'
  if (!Array.isArray(chars)) chars = chars.toString().split('')

  chars.forEach( char => {
    const repAllChars = new RegExp(char, 'g') // see: https://stackoverflow.com/a/17606289/47633
    search = search.replace(repAllChars, '.')
  })

  const regExp = new RegExp('^' + search + '$')
  return cy.wrap(subject).contains(regExp)
})

and I use it like this:

describe('my first test', () => {
  it.only('should pass', () => {
    cy.visit('http://localhost/xxxx/yyy.asp')
      .get('div.flash_error span')
      .containsLike('El código de la aplicacion no puede estar vacío.')
// it runs .contains(/^El c.digo de la aplicacion no puede estar vac.o\.$/)
  })
})
opensas
  • 60,462
  • 79
  • 252
  • 386