MCPcopy
hub / github.com/decaporg/decap-cms / beforeEach

Function beforeEach

cypress/e2e/common/spec_utils.js:22–58  ·  view source on GitHub ↗
(taskResult, backend)

Source from the content-addressed store, hash-verified

20}
21
22export 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
60export function afterEach(taskResult, backend) {
61 const spec = Cypress.mocha.getRunner().suite.ctx.currentTest.parent.title;

Callers 15

index.spec.tsFile · 0.85
index.spec.tsFile · 0.85
API.spec.jsFile · 0.85
GraphQLAPI.spec.jsFile · 0.85
index.spec.jsFile · 0.85
number.spec.jsFile · 0.85
config.spec.jsFile · 0.85
media.spec.tsFile · 0.85

Calls

no outgoing calls

Tested by 1

sharedSetupFunction · 0.68