Skip to content

Commit 28a043f

Browse files
committed
use md5 hash in e2e
1 parent 3c94150 commit 28a043f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

examples/api/e2e/base.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
import { test, expect } from "@playwright/test";
2+
import type { BinaryLike } from "node:crypto";
3+
import { createHash } from "node:crypto";
4+
5+
const OG_MD5 = "2f7b724d62d8c7739076da211aa62e7b";
6+
7+
export function validateMd5(data: Buffer, expectedHash: string) {
8+
return (
9+
createHash("md5")
10+
.update(data as BinaryLike)
11+
.digest("hex") === expectedHash
12+
);
13+
}
214

315
test("the application's noop index page is visible and it allows navigating to the hello-world api route", async ({
416
page,
@@ -47,4 +59,5 @@ test("generates an og image successfully", async ({ page }) => {
4759
const res = await page.request.get("/og");
4860
expect(res.status()).toEqual(200);
4961
expect(res.headers()["content-type"]).toEqual("image/png");
62+
expect(validateMd5(await res.body(), OG_MD5)).toEqual(true);
5063
});

0 commit comments

Comments
 (0)