You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/get-started/actions/checkLink.md
+95-9Lines changed: 95 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ You can also specify
19
19
20
20
## Examples
21
21
22
-
Here are a few ways you might you the `checkLink` action:
22
+
Here are a few ways you might use the `checkLink` action:
23
23
24
24
### Check if a link is valid
25
25
@@ -29,11 +29,11 @@ Here are a few ways you might you the `checkLink` action:
29
29
{
30
30
"steps": [
31
31
{
32
-
"description": "Check if Google is up.",
32
+
"description": "Check if Google is up.",
33
33
"action": "checkLink",
34
34
"url": "https://www.google.com"
35
35
}
36
-
],
36
+
]
37
37
}
38
38
]
39
39
}
@@ -50,11 +50,7 @@ Here are a few ways you might you the `checkLink` action:
50
50
"description": "Check if Google is up with extra status codes.",
51
51
"action": "checkLink",
52
52
"url": "https://www.google.com",
53
-
"statusCodes": [
54
-
200,
55
-
201,
56
-
202
57
-
]
53
+
"statusCodes": [200, 201, 202]
58
54
}
59
55
]
60
56
}
@@ -79,4 +75,94 @@ Here are a few ways you might you the `checkLink` action:
79
75
}
80
76
]
81
77
}
82
-
```
78
+
```
79
+
80
+
## Troubleshooting
81
+
82
+
-[`checkLink` fails due to unrecognized certificates](#checklink-fails-due-to-unrecognized-certificates)
83
+
84
+
### `checkLink` fails due to unrecognized certificates
85
+
86
+
If the `checkLink` action fails for a valid URL that loads without redirects, it may be due to an internal or custom certificate that the testing machine doesn't recognize.
87
+
88
+
#### Example
89
+
90
+
Consider the following test configuration, which checks the validity of `https://self-signed.badssl.com/`—a website using a self-signed certificate:
91
+
92
+
```json title="bad-certificate.json"
93
+
{
94
+
"tests": [
95
+
{
96
+
"steps": [
97
+
{
98
+
"description": "Check site with a self-signed certificate",
This command executes the test, but it fails, returning the following response:
116
+
117
+
```json
118
+
{
119
+
"result": "FAIL",
120
+
"resultDescription": "Invalid or unresolvable URL: https://self-signed.badssl.com/"
121
+
}
122
+
```
123
+
124
+
This occurs because the self-signed certificate isn't recognized by the testing machine. This behavior is expected in `axios`, but you can bypass it in Doc Detective by setting an environment variable.
125
+
126
+
#### Solution
127
+
128
+
To fix this issue, follow these steps:
129
+
130
+
1. Create a `.env` file with the following content:
131
+
132
+
```text title="ignore-certificate-problems.env"
133
+
NODE_TLS_REJECT_UNAUTHORIZED=0
134
+
```
135
+
136
+
2. Modify your test configuration to include a `setVariables` action:
137
+
138
+
```json title="bad-certificate.json" {5-8}
139
+
{
140
+
"tests": [
141
+
{
142
+
"steps": [
143
+
{
144
+
"action": "setVariables",
145
+
"path": "ignore-certificate-problems.env"
146
+
},
147
+
{
148
+
"description": "Check self-signed.badssl.com",
149
+
"action": "checkLink",
150
+
"url": "https://self-signed.badssl.com/",
151
+
"statusCodes": [200, 201, 202, 301]
152
+
}
153
+
]
154
+
}
155
+
]
156
+
}
157
+
```
158
+
159
+
#### Expected result
160
+
161
+
After applying these changes, the test should pass:
0 commit comments