Skip to content

Commit 966b351

Browse files
committedSep 20, 2024·
test: avoid toMatchInlineSnapshot in shared tests
1 parent 2615d39 commit 966b351

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed
 

‎test/tests.ts

+12-16
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export const describeIf = (
4747
condition
4848
? describe(title, factory)
4949
: describe(title, () => {
50-
it.skip("skipped", () => {});
50+
it.skip("skipped", () => {
51+
// Ignore
52+
});
5153
});
5254

5355
export const fixtureDir = fileURLToPath(
@@ -73,7 +75,9 @@ export async function setupTest(
7375
) {
7476
const presetTmpDir = getPresetTmpDir(preset);
7577

76-
await fsp.rm(presetTmpDir, { recursive: true }).catch(() => {});
78+
await fsp.rm(presetTmpDir, { recursive: true }).catch(() => {
79+
// Ignore
80+
});
7781
await fsp.mkdir(presetTmpDir, { recursive: true });
7882

7983
const ctx: Context = {
@@ -362,20 +366,14 @@ export function testNitro(
362366
const { status, headers } = await callHandler({ url: "/favicon.ico" });
363367
expect(status).toBe(200);
364368
expect(headers.etag).toBeDefined();
365-
expect(headers["content-type"]).toMatchInlineSnapshot(
366-
'"image/vnd.microsoft.icon"'
367-
);
369+
expect(headers["content-type"]).toBe("image/vnd.microsoft.icon");
368370
});
369371

370372
it("serve static asset /build/test.txt", async () => {
371373
const { status, headers } = await callHandler({ url: "/build/test.txt" });
372374
expect(status).toBe(200);
373-
expect(headers.etag).toMatchInlineSnapshot(
374-
`""7-vxGfAKTuGVGhpDZqQLqV60dnKPw""`
375-
);
376-
expect(headers["content-type"]).toMatchInlineSnapshot(
377-
'"text/plain; charset=utf-8"'
378-
);
375+
expect(headers.etag).toBe('"7-vxGfAKTuGVGhpDZqQLqV60dnKPw"');
376+
expect(headers["content-type"]).toBe("text/plain; charset=utf-8");
379377
});
380378

381379
it("stores content-type for prerendered routes", async () => {
@@ -394,11 +392,9 @@ export function testNitro(
394392

395393
it("find auto imported utils", async () => {
396394
const res = await callHandler({ url: "/imports" });
397-
expect(res.data).toMatchInlineSnapshot(`
398-
{
399-
"testUtil": 123,
400-
}
401-
`);
395+
expect(res.data).toMatchObject({
396+
testUtil: 123,
397+
});
402398
});
403399

404400
it.skipIf(ctx.preset === "deno-server")(

0 commit comments

Comments
 (0)
Please sign in to comment.