Skip to content

Commit ecedf68

Browse files
committed
Updated TC as per new refactoring
1 parent bbd8049 commit ecedf68

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

tests/tools/getFailureLogs.test.ts

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,29 @@ describe('BrowserStack Failure Logs', () => {
111111
});
112112

113113
describe('Automate Session Logs', () => {
114-
const mockNetworkFailures = {
115-
logs: [
114+
const mockNetworkFailures =
115+
'Network Failures (1 found):\n' +
116+
JSON.stringify([
116117
{
117118
startedDateTime: '2024-03-20T10:00:00Z',
118119
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);
123125

124126
beforeEach(() => {
125127
// Reset all mocks
126128
vi.clearAllMocks();
127-
128-
// Setup mock implementations with LogResponse objects
129+
// Setup mock implementations with string return values
129130
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+
);
132137
});
133138

134139
it('should fetch network logs successfully', async () => {
@@ -170,9 +175,15 @@ describe('BrowserStack Failure Logs', () => {
170175

171176
describe('App-Automate Session Logs', () => {
172177
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+
);
176187
});
177188

178189
it('should fetch device logs successfully', async () => {
@@ -217,7 +228,7 @@ describe('BrowserStack Failure Logs', () => {
217228

218229
describe('Error Handling', () => {
219230
it('should handle empty log responses', async () => {
220-
vi.mocked(automate.retrieveNetworkFailures).mockResolvedValue({ logs: [] });
231+
vi.mocked(automate.retrieveNetworkFailures).mockResolvedValue('No network failures found');
221232

222233
const result = await getFailureLogs({
223234
sessionId: mockSessionId,

0 commit comments

Comments
 (0)