I'm using Playwright to write an automated test for a Node.js app. The app has a test web page with a button that allows to manually select an image, which will then be processed and converted to a base64 string, which will be logged on the browser's console for verification. The automated test I'm writing simulates the manual actions and then compares the base64 string logged in the console with another one saved on a file.
The image is decoded to base64 by the FileReader class, with the readAsDataURL() method (documentation here), as shown on the snippet below:
reader.onload = () => {
EXIF.getData(file, () => {
const imageBase64 = reader.result
// more code here
})
}
reader.readAsDataURL(file)
The issue I'm facing is that when the test is run with a Chrome headed browser, the base64 is different than when it is run with a Chrome headless browser, even though the image is the same. Does anyone know why?