(taskResult, backend)
| 20 | } |
| 21 | |
| 22 | export function beforeEach(taskResult, backend) { |
| 23 | const spec = Cypress.mocha.getRunner().suite.ctx.currentTest.parent.title; |
| 24 | const testName = Cypress.mocha.getRunner().suite.ctx.currentTest.title; |
| 25 | |
| 26 | console.log(`[spec_utils.beforeEach] START backend=${backend} spec="${spec}" test="${testName}"`); |
| 27 | console.log(`[spec_utils.beforeEach] mockResponses=${taskResult.data.mockResponses}`); |
| 28 | console.log(`[spec_utils.beforeEach] user=`, JSON.stringify(taskResult.data.user || {})); |
| 29 | |
| 30 | cy.task('setupBackendTest', { |
| 31 | backend, |
| 32 | ...taskResult.data, |
| 33 | spec, |
| 34 | testName, |
| 35 | }).then(() => { |
| 36 | console.log('[spec_utils.beforeEach] setupBackendTest completed'); |
| 37 | }); |
| 38 | |
| 39 | if (taskResult.data.mockResponses) { |
| 40 | const fixture = `${spec}__${testName}.json`; |
| 41 | console.log(`[spec_utils.beforeEach] Loading fixture: ${fixture}`); |
| 42 | cy.stubFetch({ fixture }).then(() => { |
| 43 | console.log('[spec_utils.beforeEach] stubFetch completed'); |
| 44 | }); |
| 45 | } else { |
| 46 | console.log('[spec_utils.beforeEach] WARNING: mockResponses is false/undefined - no fixture loaded'); |
| 47 | } |
| 48 | |
| 49 | // cy.clock(0, ['Date']) was hanging git-gateway tests after page load |
| 50 | // Hypothesis: freezing time to 0 breaks app initialization during cy.visit() |
| 51 | // Temporary fix: skip cy.clock for git-gateway, use default clock for others |
| 52 | if (backend !== 'git-gateway') { |
| 53 | console.log('[spec_utils.beforeEach] Setting clock to epoch 0'); |
| 54 | return cy.clock(0, ['Date']); |
| 55 | } |
| 56 | |
| 57 | console.log('[spec_utils.beforeEach] COMPLETE - skipped clock for git-gateway'); |
| 58 | } |
| 59 | |
| 60 | export function afterEach(taskResult, backend) { |
| 61 | const spec = Cypress.mocha.getRunner().suite.ctx.currentTest.parent.title; |
no outgoing calls