Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
Jest toHaveBeenNthCalled escaping characters in string comparison

I'm using Jest to check the Nth call of a function, where one expected parameter is compared against a string read from a file (an HLS stream):

The expected string in question

#EXTM3U
#EXT-X-VERSION:5
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-KEY:METHOD=SAMPLE-AES,URI=\"skd://fairplay.entitlement.theplatform.eu/fpls/web/FairPlay\",KEYFORMAT=\"com.apple.streamingkeydelivery\",KEYFORMATVERSIONS=\"1\"

Being read in like:

const expectedClippedManifest = fs
    .readFileSync(path.resolve(__dirname, '../__test__/manifests/clipped-hls.m3u8'), 'utf-8')
    .toString()
    .trim();

(Note the \")

I compare with the output of my function using

expect(uploadS3).toHaveBeenNthCalledWith(
  1,
  'folderName',
  expectedClippedManifest, // The above string
  logger
);

And it seems Jest is adding escape characters to string - they are not equal.

Jest output

The left is expected, the right is received.

Text comparison

Console logging the string shows it is correct before being passed in to the comparison function; enter image description here

Is this intended behaviour, and is there a way of turning this off?

Thanks

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda