Skip to content

Commit de9e416

Browse files
committed
test: add e2e tests for proxy option
1 parent 52d48fc commit de9e416

File tree

2 files changed

+335
-980
lines changed

2 files changed

+335
-980
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,335 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`proxy option as an array respects a proxy option of function: console messages 1`] = `Array []`;
4+
5+
exports[`proxy option as an array respects a proxy option of function: page errors 1`] = `Array []`;
6+
7+
exports[`proxy option as an array respects a proxy option of function: response status 1`] = `200`;
8+
9+
exports[`proxy option as an array respects a proxy option of function: response text 1`] = `"from proxy2"`;
10+
11+
exports[`proxy option as an array respects a proxy option: console messages 1`] = `Array []`;
12+
13+
exports[`proxy option as an array respects a proxy option: page errors 1`] = `Array []`;
14+
15+
exports[`proxy option as an array respects a proxy option: response status 1`] = `200`;
16+
17+
exports[`proxy option as an array respects a proxy option: response text 1`] = `"from proxy1"`;
18+
19+
exports[`proxy option as an array should allow req, res, and next: console messages 1`] = `Array []`;
20+
21+
exports[`proxy option as an array should allow req, res, and next: page errors 1`] = `Array []`;
22+
23+
exports[`proxy option as an array should allow req, res, and next: response status 1`] = `200`;
24+
25+
exports[`proxy option as an array should allow req, res, and next: response text 1`] = `"foo+next+function"`;
26+
27+
exports[`proxy option as an array without the \`route\` option respects a proxy option: console messages 1`] = `Array []`;
28+
29+
exports[`proxy option as an array without the \`route\` option respects a proxy option: page errors 1`] = `Array []`;
30+
31+
exports[`proxy option as an array without the \`route\` option respects a proxy option: response status 1`] = `200`;
32+
33+
exports[`proxy option as an array without the \`route\` option respects a proxy option: response text 1`] = `"from proxy1"`;
34+
35+
exports[`proxy option as an object of paths with properties byPass can rewrite a request path regardless of the target defined a bypass option: console messages 1`] = `Array []`;
36+
37+
exports[`proxy option as an object of paths with properties byPass can rewrite a request path regardless of the target defined a bypass option: page errors 1`] = `Array []`;
38+
39+
exports[`proxy option as an object of paths with properties byPass can rewrite a request path regardless of the target defined a bypass option: response status 1`] = `200`;
40+
41+
exports[`proxy option as an object of paths with properties byPass can rewrite a request path regardless of the target defined a bypass option: response text 1`] = `
42+
"Hello
43+
"
44+
`;
45+
46+
exports[`proxy option as an object of paths with properties byPass can rewrite a request path: console messages 1`] = `Array []`;
47+
48+
exports[`proxy option as an object of paths with properties byPass can rewrite a request path: page errors 1`] = `Array []`;
49+
50+
exports[`proxy option as an object of paths with properties byPass can rewrite a request path: response status 1`] = `200`;
51+
52+
exports[`proxy option as an object of paths with properties byPass can rewrite a request path: response text 1`] = `
53+
"Hello
54+
"
55+
`;
56+
57+
exports[`proxy option as an object of paths with properties byPass should not pass through a proxy when a bypass function returns false: console messages 1`] = `
58+
Array [
59+
"Failed to load resource: the server responded with a status of 404 (Not Found)",
60+
]
61+
`;
62+
63+
exports[`proxy option as an object of paths with properties byPass should not pass through a proxy when a bypass function returns false: page errors 1`] = `Array []`;
64+
65+
exports[`proxy option as an object of paths with properties byPass should not pass through a proxy when a bypass function returns false: response status 1`] = `404`;
66+
67+
exports[`proxy option as an object of paths with properties byPass should not pass through a proxy when a bypass function returns false: response text 1`] = `
68+
"<!DOCTYPE html>
69+
<html lang=\\"en\\">
70+
<head>
71+
<meta charset=\\"utf-8\\">
72+
<title>Error</title>
73+
</head>
74+
<body>
75+
<pre>Cannot GET /proxyfalse</pre>
76+
</body>
77+
</html>
78+
"
79+
`;
80+
81+
exports[`proxy option as an object of paths with properties byPass should pass through a proxy when a bypass function returns null: console messages 1`] = `Array []`;
82+
83+
exports[`proxy option as an object of paths with properties byPass should pass through a proxy when a bypass function returns null: page errors 1`] = `Array []`;
84+
85+
exports[`proxy option as an object of paths with properties byPass should pass through a proxy when a bypass function returns null: response status 1`] = `200`;
86+
87+
exports[`proxy option as an object of paths with properties byPass should pass through a proxy when a bypass function returns null: response text 1`] = `
88+
"\\"use strict\\";
89+
90+
console.log(\\"Hey.\\");
91+
"
92+
`;
93+
94+
exports[`proxy option as an object of paths with properties byPass should wait if bypass returns promise: console messages 1`] = `Array []`;
95+
96+
exports[`proxy option as an object of paths with properties byPass should wait if bypass returns promise: page errors 1`] = `Array []`;
97+
98+
exports[`proxy option as an object of paths with properties byPass should wait if bypass returns promise: response status 1`] = `200`;
99+
100+
exports[`proxy option as an object of paths with properties byPass should wait if bypass returns promise: response text 1`] = `"proxy async response"`;
101+
102+
exports[`proxy option as an object of paths with properties byPass should work with the 'target' option #2: console messages 1`] = `Array []`;
103+
104+
exports[`proxy option as an object of paths with properties byPass should work with the 'target' option #2: page errors 1`] = `Array []`;
105+
106+
exports[`proxy option as an object of paths with properties byPass should work with the 'target' option #2: response status 1`] = `200`;
107+
108+
exports[`proxy option as an object of paths with properties byPass should work with the 'target' option #2: response text 1`] = `
109+
"Hello
110+
"
111+
`;
112+
113+
exports[`proxy option as an object of paths with properties byPass should work with the 'target' option: console messages 1`] = `
114+
Array [
115+
"Failed to load resource: the server responded with a status of 404 (Not Found)",
116+
]
117+
`;
118+
119+
exports[`proxy option as an object of paths with properties byPass should work with the 'target' option: page errors 1`] = `Array []`;
120+
121+
exports[`proxy option as an object of paths with properties byPass should work with the 'target' option: response status 1`] = `404`;
122+
123+
exports[`proxy option as an object of paths with properties byPass should work with the 'target' option: response text 1`] = `
124+
"<!DOCTYPE html>
125+
<html lang=\\"en\\">
126+
<head>
127+
<meta charset=\\"utf-8\\">
128+
<title>Error</title>
129+
</head>
130+
<body>
131+
<pre>Cannot GET /bypass-with-target/foo.js</pre>
132+
</body>
133+
</html>
134+
"
135+
`;
136+
137+
exports[`proxy option as an object of paths with properties pathRewrite respects a pathRewrite option: console messages 1`] = `Array []`;
138+
139+
exports[`proxy option as an object of paths with properties pathRewrite respects a pathRewrite option: page errors 1`] = `Array []`;
140+
141+
exports[`proxy option as an object of paths with properties pathRewrite respects a pathRewrite option: response status 1`] = `200`;
142+
143+
exports[`proxy option as an object of paths with properties pathRewrite respects a pathRewrite option: response text 1`] = `"from proxy2"`;
144+
145+
exports[`proxy option as an object of paths with properties target respects a proxy option when a request path is matched: console messages 1`] = `Array []`;
146+
147+
exports[`proxy option as an object of paths with properties target respects a proxy option when a request path is matched: page errors 1`] = `Array []`;
148+
149+
exports[`proxy option as an object of paths with properties target respects a proxy option when a request path is matched: response status 1`] = `200`;
150+
151+
exports[`proxy option as an object of paths with properties target respects a proxy option when a request path is matched: response text 1`] = `"from proxy1"`;
152+
153+
exports[`proxy option as an option is an object with \`context\` and \`target\` as string respects a proxy option: console messages 1`] = `Array []`;
154+
155+
exports[`proxy option as an option is an object with \`context\` and \`target\` as string respects a proxy option: page errors 1`] = `Array []`;
156+
157+
exports[`proxy option as an option is an object with \`context\` and \`target\` as string respects a proxy option: response status 1`] = `200`;
158+
159+
exports[`proxy option as an option is an object with \`context\` and \`target\` as string respects a proxy option: response text 1`] = `"from proxy1"`;
160+
161+
exports[`proxy option as an option is an object with the \`context\` option respects a proxy option: console messages 1`] = `Array []`;
162+
163+
exports[`proxy option as an option is an object with the \`context\` option respects a proxy option: page errors 1`] = `Array []`;
164+
165+
exports[`proxy option as an option is an object with the \`context\` option respects a proxy option: response status 1`] = `200`;
166+
167+
exports[`proxy option as an option is an object with the \`context\` option respects a proxy option: response text 1`] = `"from proxy1"`;
168+
169+
exports[`proxy option as an option is an object with the \`path\` option (\`context\` alias) respects a proxy option: console messages 1`] = `Array []`;
170+
171+
exports[`proxy option as an option is an object with the \`path\` option (\`context\` alias) respects a proxy option: page errors 1`] = `Array []`;
172+
173+
exports[`proxy option as an option is an object with the \`path\` option (\`context\` alias) respects a proxy option: response status 1`] = `200`;
174+
175+
exports[`proxy option as an option is an object with the \`path\` option (\`context\` alias) respects a proxy option: response text 1`] = `"from proxy1"`;
176+
177+
exports[`proxy option as an option is an object with the \`router\` option respects a proxy option: console messages 1`] = `Array []`;
178+
179+
exports[`proxy option as an option is an object with the \`router\` option respects a proxy option: page errors 1`] = `Array []`;
180+
181+
exports[`proxy option as an option is an object with the \`router\` option respects a proxy option: response status 1`] = `200`;
182+
183+
exports[`proxy option as an option is an object with the \`router\` option respects a proxy option: response text 1`] = `"from proxy1"`;
184+
185+
exports[`proxy option should handles external websocket upgrade with webSocketServerType: sockjs Should receive response: console messages 1`] = `
186+
Array [
187+
"Failed to load resource: the server responded with a status of 426 (Upgrade Required)",
188+
]
189+
`;
190+
191+
exports[`proxy option should handles external websocket upgrade with webSocketServerType: sockjs Should receive response: page errors 1`] = `Array []`;
192+
193+
exports[`proxy option should handles external websocket upgrade with webSocketServerType: sockjs Should receive response: response status 1`] = `426`;
194+
195+
exports[`proxy option should handles external websocket upgrade with webSocketServerType: sockjs Should receive response: response text 1`] = `"Upgrade Required"`;
196+
197+
exports[`proxy option should handles external websocket upgrade with webSocketServerType: ws Should receive response: console messages 1`] = `
198+
Array [
199+
"Failed to load resource: the server responded with a status of 426 (Upgrade Required)",
200+
]
201+
`;
202+
203+
exports[`proxy option should handles external websocket upgrade with webSocketServerType: ws Should receive response: page errors 1`] = `Array []`;
204+
205+
exports[`proxy option should handles external websocket upgrade with webSocketServerType: ws Should receive response: response status 1`] = `426`;
206+
207+
exports[`proxy option should handles external websocket upgrade with webSocketServerType: ws Should receive response: response text 1`] = `"Upgrade Required"`;
208+
209+
exports[`proxy option should sharing a proxy option respects proxy1 option: console messages 1`] = `Array []`;
210+
211+
exports[`proxy option should sharing a proxy option respects proxy1 option: page errors 1`] = `Array []`;
212+
213+
exports[`proxy option should sharing a proxy option respects proxy1 option: response status 1`] = `200`;
214+
215+
exports[`proxy option should sharing a proxy option respects proxy1 option: response text 1`] = `"from proxy"`;
216+
217+
exports[`proxy option should sharing a proxy option respects proxy2 option: console messages 1`] = `Array []`;
218+
219+
exports[`proxy option should sharing a proxy option respects proxy2 option: page errors 1`] = `Array []`;
220+
221+
exports[`proxy option should sharing a proxy option respects proxy2 option: response status 1`] = `200`;
222+
223+
exports[`proxy option should sharing a proxy option respects proxy2 option: response text 1`] = `"from proxy"`;
224+
225+
exports[`proxy option should supports http methods DELETE method: console messages 1`] = `Array []`;
226+
227+
exports[`proxy option should supports http methods DELETE method: page errors 1`] = `Array []`;
228+
229+
exports[`proxy option should supports http methods DELETE method: response status 1`] = `200`;
230+
231+
exports[`proxy option should supports http methods DELETE method: response text 1`] = `"DELETE method from proxy"`;
232+
233+
exports[`proxy option should supports http methods GET method: console messages 1`] = `Array []`;
234+
235+
exports[`proxy option should supports http methods GET method: page errors 1`] = `Array []`;
236+
237+
exports[`proxy option should supports http methods GET method: response status 1`] = `200`;
238+
239+
exports[`proxy option should supports http methods GET method: response text 1`] = `"GET method from proxy"`;
240+
241+
exports[`proxy option should supports http methods HEAD method: console messages 1`] = `Array []`;
242+
243+
exports[`proxy option should supports http methods HEAD method: page errors 1`] = `Array []`;
244+
245+
exports[`proxy option should supports http methods HEAD method: response status 1`] = `200`;
246+
247+
exports[`proxy option should supports http methods HEAD method: response text 1`] = `""`;
248+
249+
exports[`proxy option should supports http methods POST method (application/json): console messages 1`] = `Array []`;
250+
251+
exports[`proxy option should supports http methods POST method (application/json): page errors 1`] = `Array []`;
252+
253+
exports[`proxy option should supports http methods POST method (application/json): response headers content-type 1`] = `"application/json; charset=utf-8"`;
254+
255+
exports[`proxy option should supports http methods POST method (application/json): response status 1`] = `200`;
256+
257+
exports[`proxy option should supports http methods POST method (application/json): response text 1`] = `"{\\"answer\\":\\"POST method from proxy (id: 1)\\"}"`;
258+
259+
exports[`proxy option should supports http methods POST method (application/x-www-form-urlencoded): console messages 1`] = `Array []`;
260+
261+
exports[`proxy option should supports http methods POST method (application/x-www-form-urlencoded): page errors 1`] = `Array []`;
262+
263+
exports[`proxy option should supports http methods POST method (application/x-www-form-urlencoded): response headers content-type 1`] = `"text/html; charset=utf-8"`;
264+
265+
exports[`proxy option should supports http methods POST method (application/x-www-form-urlencoded): response status 1`] = `200`;
266+
267+
exports[`proxy option should supports http methods POST method (application/x-www-form-urlencoded): response text 1`] = `"POST method from proxy (id: 1)"`;
268+
269+
exports[`proxy option should supports http methods errors: console messages 1`] = `
270+
Array [
271+
"Failed to load resource: the server responded with a status of 500 (Internal Server Error)",
272+
]
273+
`;
274+
275+
exports[`proxy option should supports http methods errors: page errors 1`] = `Array []`;
276+
277+
exports[`proxy option should supports http methods errors: response status 1`] = `500`;
278+
279+
exports[`proxy option should supports http methods errors: response text 1`] = `"error from proxy"`;
280+
281+
exports[`proxy option should work and respect \`logProvider\` and \`logLevel\` options target respects a proxy option when a request path is matched: console messages 1`] = `
282+
Array [
283+
"Failed to load resource: the server responded with a status of 504 (Gateway Timeout)",
284+
]
285+
`;
286+
287+
exports[`proxy option should work and respect \`logProvider\` and \`logLevel\` options target respects a proxy option when a request path is matched: page errors 1`] = `Array []`;
288+
289+
exports[`proxy option should work and respect \`logProvider\` and \`logLevel\` options target respects a proxy option when a request path is matched: response status 1`] = `504`;
290+
291+
exports[`proxy option should work and respect \`logProvider\` and \`logLevel\` options target respects a proxy option when a request path is matched: response text 1`] = `"Error occured while trying to proxy: localhost:8123/my-path"`;
292+
293+
exports[`proxy option should work and respect \`logProvider\` and \`logLevel\` options with \`silent\` value target respects a proxy option when a request path is matched: console messages 1`] = `
294+
Array [
295+
"Failed to load resource: the server responded with a status of 504 (Gateway Timeout)",
296+
]
297+
`;
298+
299+
exports[`proxy option should work and respect \`logProvider\` and \`logLevel\` options with \`silent\` value target respects a proxy option when a request path is matched: page errors 1`] = `Array []`;
300+
301+
exports[`proxy option should work and respect \`logProvider\` and \`logLevel\` options with \`silent\` value target respects a proxy option when a request path is matched: response status 1`] = `504`;
302+
303+
exports[`proxy option should work and respect \`logProvider\` and \`logLevel\` options with \`silent\` value target respects a proxy option when a request path is matched: response text 1`] = `"Error occured while trying to proxy: localhost:8123/my-path"`;
304+
305+
exports[`proxy option should work and respect the \`infrastructureLogging.level\` option target respects a proxy option when a request path is matched: console messages 1`] = `
306+
Array [
307+
"Failed to load resource: the server responded with a status of 504 (Gateway Timeout)",
308+
]
309+
`;
310+
311+
exports[`proxy option should work and respect the \`infrastructureLogging.level\` option target respects a proxy option when a request path is matched: page errors 1`] = `Array []`;
312+
313+
exports[`proxy option should work and respect the \`infrastructureLogging.level\` option target respects a proxy option when a request path is matched: response status 1`] = `504`;
314+
315+
exports[`proxy option should work and respect the \`infrastructureLogging.level\` option target respects a proxy option when a request path is matched: response text 1`] = `"Error occured while trying to proxy: localhost:8123/my-path"`;
316+
317+
exports[`proxy option should work and respect the \`infrastructureLogging.level\` option with \`none\` value target respects a proxy option when a request path is matched: console messages 1`] = `
318+
Array [
319+
"Failed to load resource: the server responded with a status of 504 (Gateway Timeout)",
320+
]
321+
`;
322+
323+
exports[`proxy option should work and respect the \`infrastructureLogging.level\` option with \`none\` value target respects a proxy option when a request path is matched: page errors 1`] = `Array []`;
324+
325+
exports[`proxy option should work and respect the \`infrastructureLogging.level\` option with \`none\` value target respects a proxy option when a request path is matched: response status 1`] = `504`;
326+
327+
exports[`proxy option should work and respect the \`infrastructureLogging.level\` option with \`none\` value target respects a proxy option when a request path is matched: response text 1`] = `"Error occured while trying to proxy: localhost:8123/my-path"`;
328+
329+
exports[`proxy option should work in multi compiler mode respects a proxy option: console messages 1`] = `Array []`;
330+
331+
exports[`proxy option should work in multi compiler mode respects a proxy option: page errors 1`] = `Array []`;
332+
333+
exports[`proxy option should work in multi compiler mode respects a proxy option: response status 1`] = `200`;
334+
335+
exports[`proxy option should work in multi compiler mode respects a proxy option: response text 1`] = `"from proxy1"`;

0 commit comments

Comments
 (0)