79768587

Date: 2025-09-18 14:46:02
Score: 2.5
Natty:
Report link

I am not aware of a better answer than the process I am about to suggest.

Inside every cy.get().should().then() set of commands where I need information to be used significantly further down the test, I use cy.writefile to store the data.

Then later where this data is then required I use cy.readfile. It's chunky but it works. Example Below:

describe('Test Group',{defaultCommandTimeout: 400000}, () => {
//describe('Facit Tibi - Collage Page Elements Process',{defaultCommandTimeout: 5000}, () => {
  it('TestName', () => {
    //GLOBAL Files Created - Standard Names
    var arrFoundPeriod = Cypress.spec.name.split(".");
    var strFileNamePrefix = arrFoundPeriod[0];
    //FILES TO WRITE TO AND READ TO
    const saveSpecialData = `cypress/results/data/${strFileNamePrefix}.SpecialData.txt`;
    var strSpecialData = "First Line of Special Data:This Works But May Not Be The Best Answer"
    cy.writeFile(saveSpecialData, strSpecialData);

    cy.get(`*`)
        .should(()=>{})
        .then(elm => {
        var arrFoundPeriod = Cypress.spec.name.split(".");
        var strFileNamePrefix = arrFoundPeriod[0];            
        const saveSpecialData = `cypress/results/data/${strFileNamePrefix}.SpecialData.txt`;          

        cy.readFile(saveSpecialData).then((strOrgText) => {
            var strMoreSpecialData = "When You Find A Better Answer Please Let Me Know";
            var strNewText = `${strOrgText} ${strMoreSpecialData}`;
            cy.writeFile(saveSpecialData, strNewText);
        })
    })
  })
})
Reasons:
  • Blacklisted phrase (0.5): I need
  • RegEx Blacklisted phrase (2.5): Please Let Me Know
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Debugger Dunk