@@ -111,24 +111,29 @@ describe('BrowserStack Failure Logs', () => {
111
111
} ) ;
112
112
113
113
describe ( 'Automate Session Logs' , ( ) => {
114
- const mockNetworkFailures = {
115
- logs : [
114
+ const mockNetworkFailures =
115
+ 'Network Failures (1 found):\n' +
116
+ JSON . stringify ( [
116
117
{
117
118
startedDateTime : '2024-03-20T10:00:00Z' ,
118
119
request : { method : 'GET' , url : 'https://test.com' } ,
119
- response : { status : 404 , statusText : 'Not Found' }
120
- }
121
- ]
122
- } ;
120
+ response : { status : 404 , statusText : 'Not Found' } ,
121
+ serverIPAddress : undefined ,
122
+ time : undefined ,
123
+ } ,
124
+ ] , null , 2 ) ;
123
125
124
126
beforeEach ( ( ) => {
125
127
// Reset all mocks
126
128
vi . clearAllMocks ( ) ;
127
-
128
- // Setup mock implementations with LogResponse objects
129
+ // Setup mock implementations with string return values
129
130
vi . mocked ( automate . retrieveNetworkFailures ) . mockResolvedValue ( mockNetworkFailures ) ;
130
- vi . mocked ( automate . retrieveSessionFailures ) . mockResolvedValue ( { logs : [ '[ERROR] Test failed' ] } ) ;
131
- vi . mocked ( automate . retrieveConsoleFailures ) . mockResolvedValue ( { logs : [ 'Uncaught TypeError' ] } ) ;
131
+ vi . mocked ( automate . retrieveSessionFailures ) . mockResolvedValue (
132
+ 'Session Failures (1 found):\n' + JSON . stringify ( [ '[ERROR] Test failed' ] , null , 2 )
133
+ ) ;
134
+ vi . mocked ( automate . retrieveConsoleFailures ) . mockResolvedValue (
135
+ 'Console Failures (1 found):\n' + JSON . stringify ( [ 'Uncaught TypeError' ] , null , 2 )
136
+ ) ;
132
137
} ) ;
133
138
134
139
it ( 'should fetch network logs successfully' , async ( ) => {
@@ -170,9 +175,15 @@ describe('BrowserStack Failure Logs', () => {
170
175
171
176
describe ( 'App-Automate Session Logs' , ( ) => {
172
177
beforeEach ( ( ) => {
173
- vi . mocked ( appAutomate . retrieveDeviceLogs ) . mockResolvedValue ( { logs : [ 'Fatal Exception: NullPointerException' ] } ) ;
174
- vi . mocked ( appAutomate . retrieveAppiumLogs ) . mockResolvedValue ( { logs : [ 'Error: Element not found' ] } ) ;
175
- vi . mocked ( appAutomate . retrieveCrashLogs ) . mockResolvedValue ( { logs : [ 'Application crashed due to signal 11' ] } ) ;
178
+ vi . mocked ( appAutomate . retrieveDeviceLogs ) . mockResolvedValue (
179
+ 'Device Failures (1 found):\n' + JSON . stringify ( [ 'Fatal Exception: NullPointerException' ] , null , 2 )
180
+ ) ;
181
+ vi . mocked ( appAutomate . retrieveAppiumLogs ) . mockResolvedValue (
182
+ 'Appium Failures (1 found):\n' + JSON . stringify ( [ 'Error: Element not found' ] , null , 2 )
183
+ ) ;
184
+ vi . mocked ( appAutomate . retrieveCrashLogs ) . mockResolvedValue (
185
+ 'Crash Failures (1 found):\n' + JSON . stringify ( [ 'Application crashed due to signal 11' ] , null , 2 )
186
+ ) ;
176
187
} ) ;
177
188
178
189
it ( 'should fetch device logs successfully' , async ( ) => {
@@ -217,7 +228,7 @@ describe('BrowserStack Failure Logs', () => {
217
228
218
229
describe ( 'Error Handling' , ( ) => {
219
230
it ( 'should handle empty log responses' , async ( ) => {
220
- vi . mocked ( automate . retrieveNetworkFailures ) . mockResolvedValue ( { logs : [ ] } ) ;
231
+ vi . mocked ( automate . retrieveNetworkFailures ) . mockResolvedValue ( 'No network failures found' ) ;
221
232
222
233
const result = await getFailureLogs ( {
223
234
sessionId : mockSessionId ,
0 commit comments