browser-debugger-cli 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/__tests__/smoke/error-handling.smoke.test.js +9 -4
- package/dist/__tests__/smoke/error-handling.smoke.test.js.map +1 -1
- package/dist/__tests__/smoke/session-lifecycle.smoke.test.js +27 -24
- package/dist/__tests__/smoke/session-lifecycle.smoke.test.js.map +1 -1
- package/dist/__testutils__/daemonHelpers.d.ts +13 -1
- package/dist/__testutils__/daemonHelpers.d.ts.map +1 -1
- package/dist/__testutils__/daemonHelpers.js +54 -5
- package/dist/__testutils__/daemonHelpers.js.map +1 -1
- package/dist/cdp/protocol.d.ts.map +1 -1
- package/dist/cdp/protocol.js +9 -7
- package/dist/cdp/protocol.js.map +1 -1
- package/dist/commands/cleanup.d.ts.map +1 -1
- package/dist/commands/cleanup.js +21 -6
- package/dist/commands/cleanup.js.map +1 -1
- package/dist/commands/dom/a11y.d.ts +18 -0
- package/dist/commands/dom/a11y.d.ts.map +1 -0
- package/dist/commands/dom/a11y.js +134 -0
- package/dist/commands/dom/a11y.js.map +1 -0
- package/dist/commands/dom/evalHelpers.js +1 -1
- package/dist/commands/dom/evalHelpers.js.map +1 -1
- package/dist/commands/dom/index.d.ts.map +1 -1
- package/dist/commands/dom/index.js +41 -20
- package/dist/commands/dom/index.js.map +1 -1
- package/dist/commands/peek.d.ts.map +1 -1
- package/dist/commands/peek.js +2 -0
- package/dist/commands/peek.js.map +1 -1
- package/dist/commands/stop.d.ts.map +1 -1
- package/dist/commands/stop.js +12 -4
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/types.d.ts +3 -0
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -1
- package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.d.ts +19 -0
- package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.d.ts.map +1 -0
- package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.js +212 -0
- package/dist/daemon/__tests__/ipcServer.cleanup.unit.test.js.map +1 -0
- package/dist/daemon/launcher.d.ts.map +1 -1
- package/dist/daemon/launcher.js +4 -3
- package/dist/daemon/launcher.js.map +1 -1
- package/dist/daemon/lifecycle/workerCleanup.d.ts.map +1 -1
- package/dist/daemon/lifecycle/workerCleanup.js +1 -1
- package/dist/daemon/lifecycle/workerCleanup.js.map +1 -1
- package/dist/daemon/services/SessionService.js +1 -1
- package/dist/daemon/services/SessionService.js.map +1 -1
- package/dist/ipc/__tests__/client.contract.test.js +251 -19
- package/dist/ipc/__tests__/client.contract.test.js.map +1 -1
- package/dist/ipc/__tests__/jsonl.unit.test.js +19 -1
- package/dist/ipc/__tests__/jsonl.unit.test.js.map +1 -1
- package/dist/ipc/transport/jsonl.d.ts +16 -0
- package/dist/ipc/transport/jsonl.d.ts.map +1 -1
- package/dist/ipc/transport/jsonl.js +25 -0
- package/dist/ipc/transport/jsonl.js.map +1 -1
- package/dist/session/chrome.js +2 -2
- package/dist/session/chrome.js.map +1 -1
- package/dist/session/cleanup.d.ts +21 -0
- package/dist/session/cleanup.d.ts.map +1 -1
- package/dist/session/cleanup.js +101 -1
- package/dist/session/cleanup.js.map +1 -1
- package/dist/session/lock.js +1 -1
- package/dist/session/lock.js.map +1 -1
- package/dist/telemetry/__tests__/a11y.unit.test.d.ts +10 -0
- package/dist/telemetry/__tests__/a11y.unit.test.d.ts.map +1 -0
- package/dist/telemetry/__tests__/a11y.unit.test.js +265 -0
- package/dist/telemetry/__tests__/a11y.unit.test.js.map +1 -0
- package/dist/telemetry/a11y.d.ts +78 -0
- package/dist/telemetry/a11y.d.ts.map +1 -0
- package/dist/telemetry/a11y.js +280 -0
- package/dist/telemetry/a11y.js.map +1 -0
- package/dist/telemetry/dom.d.ts +1 -1
- package/dist/telemetry/dom.d.ts.map +1 -1
- package/dist/telemetry/dom.js +32 -1
- package/dist/telemetry/dom.js.map +1 -1
- package/dist/types.d.ts +77 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/formatters/__tests__/semantic.unit.test.d.ts +2 -0
- package/dist/ui/formatters/__tests__/semantic.unit.test.d.ts.map +1 -0
- package/dist/ui/formatters/__tests__/semantic.unit.test.js +111 -0
- package/dist/ui/formatters/__tests__/semantic.unit.test.js.map +1 -0
- package/dist/ui/formatters/a11y.d.ts +30 -0
- package/dist/ui/formatters/a11y.d.ts.map +1 -0
- package/dist/ui/formatters/a11y.js +178 -0
- package/dist/ui/formatters/a11y.js.map +1 -0
- package/dist/ui/formatters/preview.d.ts +2 -0
- package/dist/ui/formatters/preview.d.ts.map +1 -1
- package/dist/ui/formatters/preview.js +27 -4
- package/dist/ui/formatters/preview.js.map +1 -1
- package/dist/ui/formatters/semantic.d.ts +36 -0
- package/dist/ui/formatters/semantic.d.ts.map +1 -0
- package/dist/ui/formatters/semantic.js +98 -0
- package/dist/ui/formatters/semantic.js.map +1 -0
- package/dist/ui/formatters/status.js +1 -1
- package/dist/ui/formatters/status.js.map +1 -1
- package/dist/ui/messages/commands.d.ts +7 -0
- package/dist/ui/messages/commands.d.ts.map +1 -1
- package/dist/ui/messages/commands.js +9 -0
- package/dist/ui/messages/commands.js.map +1 -1
- package/dist/utils/__tests__/errors.unit.test.d.ts +12 -0
- package/dist/utils/__tests__/errors.unit.test.d.ts.map +1 -0
- package/dist/utils/__tests__/errors.unit.test.js +255 -0
- package/dist/utils/__tests__/errors.unit.test.js.map +1 -0
- package/dist/utils/__tests__/http.unit.test.d.ts +12 -0
- package/dist/utils/__tests__/http.unit.test.d.ts.map +1 -0
- package/dist/utils/__tests__/http.unit.test.js +218 -0
- package/dist/utils/__tests__/http.unit.test.js.map +1 -0
- package/dist/utils/__tests__/process.unit.test.d.ts +14 -0
- package/dist/utils/__tests__/process.unit.test.d.ts.map +1 -0
- package/dist/utils/__tests__/process.unit.test.js +124 -0
- package/dist/utils/__tests__/process.unit.test.js.map +1 -0
- package/dist/utils/__tests__/session.contract.test.js +1 -1
- package/dist/utils/__tests__/session.contract.test.js.map +1 -1
- package/package.json +22 -1
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Utilities Unit Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests error message extraction functions.
|
|
5
|
+
*
|
|
6
|
+
* Following testing philosophy:
|
|
7
|
+
* - Test the BEHAVIOR: "Always returns string, never throws"
|
|
8
|
+
* - Test the PROPERTY: "Handles all error types gracefully"
|
|
9
|
+
* - No mocking needed - pure utility function
|
|
10
|
+
*/
|
|
11
|
+
import assert from 'node:assert/strict';
|
|
12
|
+
import { describe, it } from 'node:test';
|
|
13
|
+
import { getErrorMessage } from '../../utils/errors.js';
|
|
14
|
+
void describe('Error Utilities', () => {
|
|
15
|
+
void describe('getErrorMessage()', () => {
|
|
16
|
+
void it('extracts message from Error instance', () => {
|
|
17
|
+
const error = new Error('Test error message');
|
|
18
|
+
const result = getErrorMessage(error);
|
|
19
|
+
assert.equal(result, 'Test error message');
|
|
20
|
+
});
|
|
21
|
+
void it('extracts message from TypeError instance', () => {
|
|
22
|
+
const error = new TypeError('Type mismatch');
|
|
23
|
+
const result = getErrorMessage(error);
|
|
24
|
+
assert.equal(result, 'Type mismatch');
|
|
25
|
+
});
|
|
26
|
+
void it('extracts message from RangeError instance', () => {
|
|
27
|
+
const error = new RangeError('Out of range');
|
|
28
|
+
const result = getErrorMessage(error);
|
|
29
|
+
assert.equal(result, 'Out of range');
|
|
30
|
+
});
|
|
31
|
+
void it('extracts message from custom Error subclass', () => {
|
|
32
|
+
class CustomError extends Error {
|
|
33
|
+
constructor(message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = 'CustomError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const error = new CustomError('Custom error occurred');
|
|
39
|
+
const result = getErrorMessage(error);
|
|
40
|
+
assert.equal(result, 'Custom error occurred');
|
|
41
|
+
});
|
|
42
|
+
void it('converts string to string', () => {
|
|
43
|
+
const error = 'Plain string error';
|
|
44
|
+
const result = getErrorMessage(error);
|
|
45
|
+
assert.equal(result, 'Plain string error');
|
|
46
|
+
});
|
|
47
|
+
void it('converts number to string', () => {
|
|
48
|
+
const error = 42;
|
|
49
|
+
const result = getErrorMessage(error);
|
|
50
|
+
assert.equal(result, '42');
|
|
51
|
+
});
|
|
52
|
+
void it('converts boolean to string', () => {
|
|
53
|
+
const error = false;
|
|
54
|
+
const result = getErrorMessage(error);
|
|
55
|
+
assert.equal(result, 'false');
|
|
56
|
+
});
|
|
57
|
+
void it('converts null to string "null"', () => {
|
|
58
|
+
const error = null;
|
|
59
|
+
const result = getErrorMessage(error);
|
|
60
|
+
assert.equal(result, 'null');
|
|
61
|
+
});
|
|
62
|
+
void it('converts undefined to string "undefined"', () => {
|
|
63
|
+
const error = undefined;
|
|
64
|
+
const result = getErrorMessage(error);
|
|
65
|
+
assert.equal(result, 'undefined');
|
|
66
|
+
});
|
|
67
|
+
void it('converts object to string representation', () => {
|
|
68
|
+
const error = { code: 'ERR_001', details: 'Failed' };
|
|
69
|
+
const result = getErrorMessage(error);
|
|
70
|
+
assert.equal(result, '[object Object]');
|
|
71
|
+
});
|
|
72
|
+
void it('converts array to string representation', () => {
|
|
73
|
+
const error = ['error1', 'error2'];
|
|
74
|
+
const result = getErrorMessage(error);
|
|
75
|
+
assert.equal(result, 'error1,error2');
|
|
76
|
+
});
|
|
77
|
+
void it('handles Error with empty message', () => {
|
|
78
|
+
const error = new Error('');
|
|
79
|
+
const result = getErrorMessage(error);
|
|
80
|
+
assert.equal(result, '');
|
|
81
|
+
});
|
|
82
|
+
void it('handles Error with multiline message', () => {
|
|
83
|
+
const error = new Error('Line 1\nLine 2\nLine 3');
|
|
84
|
+
const result = getErrorMessage(error);
|
|
85
|
+
assert.equal(result, 'Line 1\nLine 2\nLine 3');
|
|
86
|
+
});
|
|
87
|
+
void it('handles Error with special characters in message', () => {
|
|
88
|
+
const error = new Error('Error: "quoted" & <special> chars');
|
|
89
|
+
const result = getErrorMessage(error);
|
|
90
|
+
assert.equal(result, 'Error: "quoted" & <special> chars');
|
|
91
|
+
});
|
|
92
|
+
void it('handles Error with unicode characters', () => {
|
|
93
|
+
const error = new Error('Error: 你好 🚀');
|
|
94
|
+
const result = getErrorMessage(error);
|
|
95
|
+
assert.equal(result, 'Error: 你好 🚀');
|
|
96
|
+
});
|
|
97
|
+
void it('handles object with custom toString method', () => {
|
|
98
|
+
const error = {
|
|
99
|
+
toString() {
|
|
100
|
+
return 'Custom toString result';
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
const result = getErrorMessage(error);
|
|
104
|
+
assert.equal(result, 'Custom toString result');
|
|
105
|
+
});
|
|
106
|
+
void it('always returns string type regardless of input', () => {
|
|
107
|
+
const testCases = [
|
|
108
|
+
new Error('error'),
|
|
109
|
+
'string',
|
|
110
|
+
42,
|
|
111
|
+
true,
|
|
112
|
+
null,
|
|
113
|
+
undefined,
|
|
114
|
+
{},
|
|
115
|
+
[],
|
|
116
|
+
Symbol('test'),
|
|
117
|
+
];
|
|
118
|
+
for (const testCase of testCases) {
|
|
119
|
+
const result = getErrorMessage(testCase);
|
|
120
|
+
assert.equal(typeof result, 'string', `Should return string for ${String(testCase)}`);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
void it('never throws for common input types', () => {
|
|
124
|
+
const commonInputs = [
|
|
125
|
+
new Error('error'),
|
|
126
|
+
null,
|
|
127
|
+
undefined,
|
|
128
|
+
{ [Symbol.toStringTag]: 'Custom' },
|
|
129
|
+
Symbol('symbol'),
|
|
130
|
+
BigInt(123),
|
|
131
|
+
];
|
|
132
|
+
for (const input of commonInputs) {
|
|
133
|
+
assert.doesNotThrow(() => {
|
|
134
|
+
getErrorMessage(input);
|
|
135
|
+
}, `Should not throw for common input`);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
void it('handles objects with no prototype', () => {
|
|
139
|
+
const noProto = Object.create(null);
|
|
140
|
+
// This is expected JavaScript behavior - String() requires prototype chain
|
|
141
|
+
try {
|
|
142
|
+
const result = getErrorMessage(noProto);
|
|
143
|
+
assert.equal(typeof result, 'string', 'Should return string if conversion succeeds');
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
// Object.create(null) throws in String() - this is expected JS behavior
|
|
147
|
+
assert.ok(error instanceof TypeError, 'Should throw TypeError for null-prototype objects');
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
void it('handles Proxy objects gracefully', () => {
|
|
151
|
+
// Proxy with trap that prevents primitive conversion
|
|
152
|
+
const problematicProxy = new Proxy({}, {
|
|
153
|
+
get() {
|
|
154
|
+
return undefined;
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
try {
|
|
158
|
+
const result = getErrorMessage(problematicProxy);
|
|
159
|
+
assert.equal(typeof result, 'string', 'Should return string if successful');
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// Proxies with certain traps can throw - this is acceptable behavior
|
|
163
|
+
// The function correctly converts what it can; exotic Proxies are edge cases
|
|
164
|
+
assert.ok(true, 'Exotic Proxy behavior is acceptable');
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
void it('handles Error with cause property (Node.js 16.9+)', () => {
|
|
168
|
+
const cause = new Error('Root cause');
|
|
169
|
+
const error = new Error('Wrapper error', { cause });
|
|
170
|
+
const result = getErrorMessage(error);
|
|
171
|
+
assert.equal(result, 'Wrapper error');
|
|
172
|
+
assert.notEqual(result, 'Root cause');
|
|
173
|
+
});
|
|
174
|
+
void it('handles AggregateError with multiple errors', () => {
|
|
175
|
+
const errors = [new Error('Error 1'), new Error('Error 2')];
|
|
176
|
+
const aggregateError = new AggregateError(errors, 'Multiple failures');
|
|
177
|
+
const result = getErrorMessage(aggregateError);
|
|
178
|
+
assert.equal(result, 'Multiple failures');
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
void describe('Common error handling patterns', () => {
|
|
182
|
+
void it('works in try-catch blocks with unknown error type', () => {
|
|
183
|
+
function throwRandomError() {
|
|
184
|
+
throw new Error('Random error');
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
throwRandomError();
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
const message = getErrorMessage(error);
|
|
191
|
+
assert.equal(message, 'Random error');
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
void it('handles rejection values from promises', async () => {
|
|
195
|
+
const promise = Promise.reject(new Error('Promise rejected with string'));
|
|
196
|
+
try {
|
|
197
|
+
await promise;
|
|
198
|
+
assert.fail('Should have rejected');
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
const message = getErrorMessage(error);
|
|
202
|
+
assert.equal(message, 'Promise rejected with string');
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
void it('extracts message from fetch errors', () => {
|
|
206
|
+
// Simulate fetch error
|
|
207
|
+
const fetchError = new TypeError('fetch failed');
|
|
208
|
+
const message = getErrorMessage(fetchError);
|
|
209
|
+
assert.equal(message, 'fetch failed');
|
|
210
|
+
});
|
|
211
|
+
void it('handles file system errors with code property', () => {
|
|
212
|
+
const fsError = new Error('ENOENT: no such file or directory');
|
|
213
|
+
fsError.code = 'ENOENT';
|
|
214
|
+
fsError.path = '/tmp/missing-file.txt';
|
|
215
|
+
const message = getErrorMessage(fsError);
|
|
216
|
+
assert.ok(message.includes('ENOENT'));
|
|
217
|
+
assert.ok(message.includes('no such file'));
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
void describe('Type safety and edge cases', () => {
|
|
221
|
+
void it('handles circular reference in object', () => {
|
|
222
|
+
const circular = {};
|
|
223
|
+
circular.self = circular;
|
|
224
|
+
assert.doesNotThrow(() => {
|
|
225
|
+
const result = getErrorMessage(circular);
|
|
226
|
+
assert.equal(typeof result, 'string');
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
void it('handles very long error messages', () => {
|
|
230
|
+
const longMessage = 'A'.repeat(10000);
|
|
231
|
+
const error = new Error(longMessage);
|
|
232
|
+
const result = getErrorMessage(error);
|
|
233
|
+
assert.equal(result.length, 10000);
|
|
234
|
+
assert.equal(result, longMessage);
|
|
235
|
+
});
|
|
236
|
+
void it('handles Error with non-standard properties', () => {
|
|
237
|
+
const error = new Error('Standard message');
|
|
238
|
+
error.customProp = 'custom value';
|
|
239
|
+
const result = getErrorMessage(error);
|
|
240
|
+
assert.equal(result, 'Standard message');
|
|
241
|
+
});
|
|
242
|
+
void it('handles Symbol as error', () => {
|
|
243
|
+
const symbolError = Symbol('error symbol');
|
|
244
|
+
const result = getErrorMessage(symbolError);
|
|
245
|
+
assert.ok(result.includes('Symbol'));
|
|
246
|
+
assert.ok(result.includes('error symbol'));
|
|
247
|
+
});
|
|
248
|
+
void it('handles BigInt as error', () => {
|
|
249
|
+
const bigIntError = BigInt(9007199254740991);
|
|
250
|
+
const result = getErrorMessage(bigIntError);
|
|
251
|
+
assert.equal(result, '9007199254740991');
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
//# sourceMappingURL=errors.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.unit.test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/errors.unit.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,KAAK,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IACpC,KAAK,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACtC,KAAK,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YACnD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,o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yB,EAAE,GAAG,EAAE;YACtC,MAAM,WAAW,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;YAE7C,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;YAE5C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Utilities Unit Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests CDP HTTP API client functions.
|
|
5
|
+
*
|
|
6
|
+
* Following testing philosophy:
|
|
7
|
+
* - Test the BEHAVIOR: "HTTP errors return empty arrays, not throw"
|
|
8
|
+
* - Test the PROPERTY: "Timeout always triggers after specified duration"
|
|
9
|
+
* - Mock the BOUNDARY: fetch() (external HTTP dependency)
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=http.unit.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.unit.test.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/http.unit.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Utilities Unit Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests CDP HTTP API client functions.
|
|
5
|
+
*
|
|
6
|
+
* Following testing philosophy:
|
|
7
|
+
* - Test the BEHAVIOR: "HTTP errors return empty arrays, not throw"
|
|
8
|
+
* - Test the PROPERTY: "Timeout always triggers after specified duration"
|
|
9
|
+
* - Mock the BOUNDARY: fetch() (external HTTP dependency)
|
|
10
|
+
*/
|
|
11
|
+
import assert from 'node:assert/strict';
|
|
12
|
+
import { afterEach, beforeEach, describe, it, mock } from 'node:test';
|
|
13
|
+
import { fetchCDPTargetById, fetchCDPTargets } from '../../utils/http.js';
|
|
14
|
+
void describe('HTTP Utilities', () => {
|
|
15
|
+
let originalFetch;
|
|
16
|
+
let fetchMock;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
originalFetch = global.fetch;
|
|
19
|
+
fetchMock = mock.fn(global.fetch);
|
|
20
|
+
global.fetch = fetchMock;
|
|
21
|
+
});
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
global.fetch = originalFetch;
|
|
24
|
+
});
|
|
25
|
+
void describe('fetchCDPTargets()', () => {
|
|
26
|
+
void it('returns array of targets when HTTP request succeeds', async () => {
|
|
27
|
+
const mockTargets = [
|
|
28
|
+
{
|
|
29
|
+
id: 'target-1',
|
|
30
|
+
title: 'Page 1',
|
|
31
|
+
url: 'http://localhost:3000',
|
|
32
|
+
webSocketDebuggerUrl: 'ws://...',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'target-2',
|
|
36
|
+
title: 'Page 2',
|
|
37
|
+
url: 'http://localhost:3001',
|
|
38
|
+
webSocketDebuggerUrl: 'ws://...',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
fetchMock.mock.mockImplementation(() => Promise.resolve({
|
|
42
|
+
ok: true,
|
|
43
|
+
json: () => Promise.resolve(mockTargets),
|
|
44
|
+
}));
|
|
45
|
+
const result = await fetchCDPTargets(9222);
|
|
46
|
+
assert.ok(Array.isArray(result), 'Result should be an array');
|
|
47
|
+
assert.equal(result.length, 2, 'Should return 2 targets');
|
|
48
|
+
assert.equal(result[0]?.id, 'target-1');
|
|
49
|
+
assert.equal(result[1]?.id, 'target-2');
|
|
50
|
+
});
|
|
51
|
+
void it('returns empty array when HTTP response is not ok (404, 500, etc.)', async () => {
|
|
52
|
+
fetchMock.mock.mockImplementation(() => Promise.resolve({
|
|
53
|
+
ok: false,
|
|
54
|
+
status: 404,
|
|
55
|
+
statusText: 'Not Found',
|
|
56
|
+
}));
|
|
57
|
+
const result = await fetchCDPTargets(9222);
|
|
58
|
+
assert.ok(Array.isArray(result), 'Result should be an array');
|
|
59
|
+
assert.equal(result.length, 0, 'Should return empty array on HTTP error');
|
|
60
|
+
});
|
|
61
|
+
void it('returns empty array when response is not valid JSON array', async () => {
|
|
62
|
+
fetchMock.mock.mockImplementation(() => Promise.resolve({
|
|
63
|
+
ok: true,
|
|
64
|
+
json: () => Promise.resolve({ error: 'Invalid format' }),
|
|
65
|
+
}));
|
|
66
|
+
const result = await fetchCDPTargets(9222);
|
|
67
|
+
assert.ok(Array.isArray(result), 'Result should be an array');
|
|
68
|
+
assert.equal(result.length, 0, 'Should return empty array when response is not array');
|
|
69
|
+
});
|
|
70
|
+
void it('returns empty array when network error occurs', async () => {
|
|
71
|
+
fetchMock.mock.mockImplementation(() => Promise.reject(new Error('Network error')));
|
|
72
|
+
const result = await fetchCDPTargets(9222);
|
|
73
|
+
assert.ok(Array.isArray(result), 'Result should be an array');
|
|
74
|
+
assert.equal(result.length, 0, 'Should return empty array on network error');
|
|
75
|
+
});
|
|
76
|
+
void it('returns empty array when request times out after 5 seconds', async () => {
|
|
77
|
+
fetchMock.mock.mockImplementation((_url, options) => {
|
|
78
|
+
return new Promise((_resolve, reject) => {
|
|
79
|
+
// Simulate timeout by checking if signal is aborted
|
|
80
|
+
if (options?.signal) {
|
|
81
|
+
options.signal.addEventListener('abort', () => {
|
|
82
|
+
const error = new Error('Request aborted');
|
|
83
|
+
error.name = 'AbortError';
|
|
84
|
+
reject(error);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
const result = await fetchCDPTargets(9222);
|
|
90
|
+
assert.ok(Array.isArray(result), 'Result should be an array');
|
|
91
|
+
assert.equal(result.length, 0, 'Should return empty array on timeout');
|
|
92
|
+
});
|
|
93
|
+
void it('uses default port 9222 when port not specified', async () => {
|
|
94
|
+
let requestedUrl = '';
|
|
95
|
+
fetchMock.mock.mockImplementation((url) => {
|
|
96
|
+
requestedUrl = url;
|
|
97
|
+
return Promise.resolve({
|
|
98
|
+
ok: true,
|
|
99
|
+
json: () => Promise.resolve([]),
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
await fetchCDPTargets();
|
|
103
|
+
assert.ok(requestedUrl.includes(':9222'), 'Should use default port 9222');
|
|
104
|
+
});
|
|
105
|
+
void it('uses custom port when specified', async () => {
|
|
106
|
+
let requestedUrl = '';
|
|
107
|
+
fetchMock.mock.mockImplementation((url) => {
|
|
108
|
+
requestedUrl = url;
|
|
109
|
+
return Promise.resolve({
|
|
110
|
+
ok: true,
|
|
111
|
+
json: () => Promise.resolve([]),
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
await fetchCDPTargets(9223);
|
|
115
|
+
assert.ok(requestedUrl.includes(':9223'), 'Should use custom port 9223');
|
|
116
|
+
});
|
|
117
|
+
void it('constructs correct CDP HTTP endpoint URL', async () => {
|
|
118
|
+
let requestedUrl = '';
|
|
119
|
+
fetchMock.mock.mockImplementation((url) => {
|
|
120
|
+
requestedUrl = url;
|
|
121
|
+
return Promise.resolve({
|
|
122
|
+
ok: true,
|
|
123
|
+
json: () => Promise.resolve([]),
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
await fetchCDPTargets(9222);
|
|
127
|
+
assert.ok(requestedUrl.startsWith('http://'), 'Should use HTTP protocol');
|
|
128
|
+
assert.ok(requestedUrl.includes('/json/list'), 'Should use /json/list endpoint');
|
|
129
|
+
assert.ok(requestedUrl.includes('127.0.0.1'), 'Should use localhost');
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
void describe('fetchCDPTargetById()', () => {
|
|
133
|
+
void it('returns matching target when ID exists', async () => {
|
|
134
|
+
const mockTargets = [
|
|
135
|
+
{
|
|
136
|
+
id: 'target-1',
|
|
137
|
+
title: 'Page 1',
|
|
138
|
+
url: 'http://localhost:3000',
|
|
139
|
+
webSocketDebuggerUrl: 'ws://...',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: 'target-2',
|
|
143
|
+
title: 'Page 2',
|
|
144
|
+
url: 'http://localhost:3001',
|
|
145
|
+
webSocketDebuggerUrl: 'ws://...',
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
fetchMock.mock.mockImplementation(() => Promise.resolve({
|
|
149
|
+
ok: true,
|
|
150
|
+
json: () => Promise.resolve(mockTargets),
|
|
151
|
+
}));
|
|
152
|
+
const result = await fetchCDPTargetById('target-2', 9222);
|
|
153
|
+
assert.ok(result !== null, 'Should return a target');
|
|
154
|
+
assert.equal(result?.id, 'target-2');
|
|
155
|
+
assert.equal(result?.title, 'Page 2');
|
|
156
|
+
});
|
|
157
|
+
void it('returns null when target ID not found', async () => {
|
|
158
|
+
const mockTargets = [
|
|
159
|
+
{
|
|
160
|
+
id: 'target-1',
|
|
161
|
+
title: 'Page 1',
|
|
162
|
+
url: 'http://localhost:3000',
|
|
163
|
+
webSocketDebuggerUrl: 'ws://...',
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
fetchMock.mock.mockImplementation(() => Promise.resolve({
|
|
167
|
+
ok: true,
|
|
168
|
+
json: () => Promise.resolve(mockTargets),
|
|
169
|
+
}));
|
|
170
|
+
const result = await fetchCDPTargetById('nonexistent', 9222);
|
|
171
|
+
assert.equal(result, null, 'Should return null when target not found');
|
|
172
|
+
});
|
|
173
|
+
void it('returns null when HTTP request fails', async () => {
|
|
174
|
+
fetchMock.mock.mockImplementation(() => Promise.resolve({
|
|
175
|
+
ok: false,
|
|
176
|
+
status: 500,
|
|
177
|
+
}));
|
|
178
|
+
const result = await fetchCDPTargetById('target-1', 9222);
|
|
179
|
+
assert.equal(result, null, 'Should return null on HTTP error');
|
|
180
|
+
});
|
|
181
|
+
void it('returns null when network error occurs', async () => {
|
|
182
|
+
fetchMock.mock.mockImplementation(() => Promise.reject(new Error('Network error')));
|
|
183
|
+
const result = await fetchCDPTargetById('target-1', 9222);
|
|
184
|
+
assert.equal(result, null, 'Should return null on network error');
|
|
185
|
+
});
|
|
186
|
+
void it('returns null when targets list is empty', async () => {
|
|
187
|
+
fetchMock.mock.mockImplementation(() => Promise.resolve({
|
|
188
|
+
ok: true,
|
|
189
|
+
json: () => Promise.resolve([]),
|
|
190
|
+
}));
|
|
191
|
+
const result = await fetchCDPTargetById('target-1', 9222);
|
|
192
|
+
assert.equal(result, null, 'Should return null when no targets found');
|
|
193
|
+
});
|
|
194
|
+
void it('uses default port 9222 when port not specified', async () => {
|
|
195
|
+
let requestedUrl = '';
|
|
196
|
+
fetchMock.mock.mockImplementation((url) => {
|
|
197
|
+
requestedUrl = url;
|
|
198
|
+
return Promise.resolve({
|
|
199
|
+
ok: true,
|
|
200
|
+
json: () => Promise.resolve([]),
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
await fetchCDPTargetById('target-1');
|
|
204
|
+
assert.ok(requestedUrl.includes(':9222'), 'Should use default port 9222');
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
void describe('Error handling consistency', () => {
|
|
208
|
+
void it('both functions handle errors the same way (return empty/null, not throw)', async () => {
|
|
209
|
+
fetchMock.mock.mockImplementation(() => Promise.reject(new Error('Network failure')));
|
|
210
|
+
const targetsResult = await fetchCDPTargets(9222);
|
|
211
|
+
const targetResult = await fetchCDPTargetById('target-1', 9222);
|
|
212
|
+
assert.ok(Array.isArray(targetsResult), 'fetchCDPTargets should return array');
|
|
213
|
+
assert.equal(targetsResult.length, 0, 'fetchCDPTargets should return empty array');
|
|
214
|
+
assert.equal(targetResult, null, 'fetchCDPTargetById should return null');
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
//# sourceMappingURL=http.unit.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.unit.test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/http.unit.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,UAAU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|
+
* - Test the BEHAVIOR: "isProcessAlive returns true for running processes"
|
|
8
|
+
* - Test the PROPERTY: "Signal 0 check doesn't affect process state"
|
|
9
|
+
* - Test CROSS-PLATFORM: Different behavior on Windows vs Unix
|
|
10
|
+
*
|
|
11
|
+
* Note: Some tests use the current process (process.pid) which is guaranteed to be alive.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=process.unit.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.unit.test.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/process.unit.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|