-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (34 loc) · 1.6 KB
/
script.js
File metadata and controls
42 lines (34 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(function () {
try {
// URL completa con variables ya resueltas
const rawUrl = pm.request && pm.request.url ? pm.request.url.toString() : '';
// (Opcional) Limitar longitud para evitar inflar el JSON final
const MAX = 2000;
const recorte = rawUrl.length > MAX ? rawUrl.slice(0, MAX) + '...[TRUNCADO]' : rawUrl;
// Base64 seguro para Unicode
const base64 = btoa(unescape(encodeURIComponent(recorte)));
// Patrón: __URL__<requestId>__<iter>__<base64>
// IMPORTANTE: No insertes segmentos extra con '__' o romperías el parser.
const reqId = (pm.request && pm.request.id) ? pm.request.id : 'undefined';
const iter = pm.info && typeof pm.info.iteration !== 'undefined' ? pm.info.iteration : 0;
const testName = `__URL__${reqId}__${iter}__${base64}`;
pm.test(testName, function () {
pm.expect(true).to.be.true;
});
} catch (e) {
console.log('Error creando test __URL__', e);
}
})();
(function () {
const raw = pm.response.text() || '';
// Limitar (por ejemplo) a 4000 caracteres para no inflar demasiado el JSON
const max = 4000;
const recorte = raw.length > max ? raw.slice(0, max) + '...[TRUNCADO]' : raw;
// Codificar para que no rompa el JSON del reporte (Base64)
const base64 = btoa(unescape(encodeURIComponent(recorte)));
// Nombre especial de test: __BODY__<requestId>__<iter>__<base64>
const testName = `__BODY__${pm.request.id}__${pm.info.iteration}__${base64}`;
pm.test(testName, function () {
pm.expect(true).to.be.true;
});
})();