Skip to content

Commit 9380991

Browse files
snitin315alexander-akait
authored andcommitted
test: refactor normalize options tests to cleanup properly (#4922)
1 parent cf0f883 commit 9380991

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

test/normalize-options.test.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -587,28 +587,32 @@ describe("normalize options", () => {
587587
errored = error;
588588
}
589589

590-
if (item.throws) {
591-
expect(errored.message).toMatch(item.throws);
592-
} else {
593-
const optionsForSnapshot = klona(server.options);
590+
try {
591+
if (item.throws) {
592+
expect(errored.message).toMatch(item.throws);
593+
} else {
594+
const optionsForSnapshot = klona(server.options);
594595

595-
optionsForSnapshot.port = "<auto>";
596+
optionsForSnapshot.port = "<auto>";
596597

597-
if (optionsForSnapshot.static.length > 0) {
598-
optionsForSnapshot.static.forEach((i) => {
599-
i.directory = i.directory
600-
.replace(/\\/g, "/")
601-
.replace(
602-
new RegExp(process.cwd().replace(/\\/g, "/"), "g"),
603-
"<cwd>"
604-
);
605-
});
606-
}
598+
if (optionsForSnapshot.static.length > 0) {
599+
optionsForSnapshot.static.forEach((i) => {
600+
i.directory = i.directory
601+
.replace(/\\/g, "/")
602+
.replace(
603+
new RegExp(process.cwd().replace(/\\/g, "/"), "g"),
604+
"<cwd>"
605+
);
606+
});
607+
}
607608

608-
expect(optionsForSnapshot).toMatchSnapshot();
609+
expect(optionsForSnapshot).toMatchSnapshot();
610+
}
611+
} catch (error) {
612+
throw error;
613+
} finally {
614+
await server.stop();
609615
}
610-
611-
await server.stop();
612616
});
613617
});
614618
});

0 commit comments

Comments
 (0)