+async function testImage (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') {
+ const res = await makeGetRequest({
+ url,
+ path: imageHTTPPath,
+ expectedStatus: HttpStatusCode.OK_200
+ })
+
+ const body = res.body
+ const data = await readFile(join(root(), 'server', 'tests', 'fixtures', imageName + extension))
+
+ const img1 = imageHTTPPath.endsWith('.png')
+ ? PNG.sync.read(body)
+ : JPEG.decode(body)
+
+ const img2 = extension === '.png'
+ ? PNG.sync.read(data)
+ : JPEG.decode(data)
+
+ const result = pixelmatch(img1.data, img2.data, null, img1.width, img1.height, { threshold: 0.1 })
+
+ expect(result).to.equal(0, `${imageHTTPPath} image is not the same as ${imageName}${extension}`)
+}
+