Skip to content

Commit cb3ab69

Browse files
committed
fix(cypress): enhance logging for better traceability during tests and setup
1 parent a748cc1 commit cb3ab69

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

cypress/e2e/common/media_library.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,18 @@ function assertGridEntryImage(entry) {
102102

103103
export default function({ entries, getUser }) {
104104
beforeEach(() => {
105+
console.log(`[${new Date().toISOString()}] [media_library beforeEach] Starting, about to call login`);
105106
login(getUser && getUser());
107+
console.log(`[${new Date().toISOString()}] [media_library beforeEach] login completed`);
106108
});
107109

108110
it('can upload image from global media library', () => {
111+
console.log(`[${new Date().toISOString()}] [TEST] Starting: can upload image from global media library`);
109112
goToMediaLibrary();
110113
uploadMediaFile();
111114
matchImageSnapshot();
112115
closeMediaLibrary();
116+
console.log(`[${new Date().toISOString()}] [TEST] Completed: can upload image from global media library`);
113117
});
114118

115119
it('can delete image from global media library', () => {

cypress/e2e/common/spec_utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export function beforeEach(taskResult, backend) {
1717
const spec = Cypress.mocha.getRunner().suite.ctx.currentTest.parent.title;
1818
const testName = Cypress.mocha.getRunner().suite.ctx.currentTest.title;
1919

20+
console.log(`[${new Date().toISOString()}] [beforeEach] Starting for backend: ${backend}`);
21+
console.log(`[${new Date().toISOString()}] [beforeEach] mockResponses:`, taskResult.data.mockResponses);
22+
2023
cy.task('setupBackendTest', {
2124
backend,
2225
...taskResult.data,
@@ -34,8 +37,11 @@ export function beforeEach(taskResult, backend) {
3437
// Hypothesis: freezing time to 0 breaks app initialization during cy.visit()
3538
// Temporary fix: skip cy.clock for git-gateway, use default clock for others
3639
if (backend !== 'git-gateway') {
40+
console.log(`[${new Date().toISOString()}] [beforeEach] Setting clock to epoch 0 for non-git-gateway`);
3741
return cy.clock(0, ['Date']);
3842
}
43+
44+
console.log(`[${new Date().toISOString()}] [beforeEach] Skipped clock for git-gateway`);
3945
}
4046

4147
export function afterEach(taskResult, backend) {

cypress/plugins/gitGateway.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ async function setupGitGateway(options) {
269269
provider,
270270
};
271271
} else {
272+
console.log('Running tests in "playback" mode - local data will be used');
272273
return {
273274
...result,
274275
user: {
@@ -279,6 +280,7 @@ async function setupGitGateway(options) {
279280
password,
280281
},
281282
provider,
283+
mockResponses: true,
282284
};
283285
}
284286
}

cypress/utils/steps.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ const {
99
} = require('./constants');
1010

1111
function login(user) {
12+
console.log(`[${new Date().toISOString()}] [login] Starting with user:`, user ? 'yes' : 'no', user?.netlifySiteURL ? 'has site URL' : 'no site URL');
1213
cy.viewport(1200, 1200);
1314
if (user) {
15+
console.log(`[${new Date().toISOString()}] [login] About to cy.visit('/')`);
1416
cy.visit('/', {
1517
onBeforeLoad: () => {
1618
// https://github.com/cypress-io/cypress/issues/1208
@@ -19,20 +21,26 @@ function login(user) {
1921
if (user.netlifySiteURL) {
2022
window.localStorage.setItem('netlifySiteURL', user.netlifySiteURL);
2123
}
24+
console.log(`[${new Date().toISOString()}] [login] onBeforeLoad complete, localStorage set`);
2225
},
2326
});
27+
console.log(`[${new Date().toISOString()}] [login] cy.visit('/') queued`);
2428
if (user.netlifySiteURL && user.email && user.password) {
29+
console.log(`[${new Date().toISOString()}] [login] About to fill login form`);
2530
cy.get('input[name="email"]').clear();
2631
cy.get('input[name="email"]').type(user.email);
2732
cy.get('input[name="password"]').clear();
2833
cy.get('input[name="password"]').type(user.password);
2934
cy.contains('button', 'Login').click();
35+
console.log(`[${new Date().toISOString()}] [login] Login button clicked`);
3036
}
3137
} else {
3238
cy.visit('/');
3339
cy.contains('button', 'Login').click();
3440
}
41+
console.log(`[${new Date().toISOString()}] [login] About to wait for "New Post" link`);
3542
cy.contains('a', 'New Post');
43+
console.log(`[${new Date().toISOString()}] [login] "New Post" link found - login complete`);
3644
}
3745

3846
function assertNotification(message) {

0 commit comments

Comments
 (0)