Skip to content

Commit 92ee00f

Browse files
committed
Improve handling of lintcert network errors in tests
1 parent 8108e80 commit 92ee00f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

test/ca.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ nodeOnly(() => {
6060
});
6161

6262
it("should be able to generate a CA certificate that passes lintcert checks", async function () {
63+
this.retries(3); // Remote server can be unreliable
64+
6365
const caCertificate = await caCertificatePromise;
6466

6567
const { cert } = caCertificate;
@@ -89,6 +91,7 @@ nodeOnly(() => {
8991

9092
it("should generate CA certs that can be used to create domain certs that pass lintcert checks", async function () {
9193
this.timeout(5000); // Large cert + remote request can make this slow
94+
this.retries(3); // Remote server can be unreliable
9295

9396
const caCertificate = await caCertificatePromise;
9497
const ca = new CA({ key: caCertificate.key, cert: caCertificate.cert, keyLength: 2048 });
@@ -132,6 +135,7 @@ nodeOnly(() => {
132135

133136
it("should generate wildcard certs that pass lintcert checks for invalid subdomain names", async function () {
134137
this.timeout(5000); // Large cert + remote request can make this slow
138+
this.retries(3); // Remote server can be unreliable
135139

136140
const caCertificate = await caCertificatePromise;
137141
const ca = new CA({ key: caCertificate.key, cert: caCertificate.cert, keyLength: 2048 });

test/test-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ export async function ignoreNetworkError<T extends RequestPromise | Promise<Resp
108108
const TimeoutError = new Error('timeout');
109109

110110
const result = await Promise.race([
111-
request.catch(e => e),
112-
delay(options.timeout ?? 1000).then(() => { throw TimeoutError })
111+
request,
112+
delay(options.timeout ?? 1000).then(() => { throw TimeoutError; })
113113
]).catch(error => {
114114
console.log(error);
115115
if (error === TimeoutError) {

0 commit comments

Comments
 (0)