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.
The left is expected, the right is received.
Console logging the string shows it is correct before being passed in to the comparison function;

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