Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parent session should be restored with the original timestamps #43

Closed
bahmutov opened this issue Jan 4, 2022 · 1 comment
Closed

parent session should be restored with the original timestamps #43

bahmutov opened this issue Jan 4, 2022 · 1 comment
Labels

Comments

@bahmutov
Copy link
Owner

bahmutov commented Jan 4, 2022

When using recreate and restoring a shared session we need to make sure the original timestamps are used, otherwise the child session gets recomputed

spec cypress/integration/env-restore-shared.js

describe('Restores data session', () => {
  beforeEach(() => {
    Cypress.clearDataSession('parent')
    Cypress.clearDataSession('child')
  })

  it('sets the session in Cypress.env', function () {
    /** @type Cypress.DataSessionOptions */
    const parentOptions = {
      name: 'parent',
      setup: cy.stub().as('parentSetup').returns(1),
      recreate: cy.stub().as('parentRecreate').returns(2),
      validate: true,
      shareAcrossSpecs: true,
    }

    /** @type Cypress.DataSessionOptions */
    const childOptions = {
      name: 'child',
      setup: cy.stub().as('childSetup').returns(1),
      validate: true,
      dependsOn: 'parent',
    }

    const key = Cypress.formDataSessionKey('parent')

    cy.dataSession(parentOptions)
    cy.dataSession(childOptions)
      .then(() => {
        delete Cypress.env()[key]
      })
      .then(() => {
        cy.dataSession(parentOptions)
        cy.dataSession(childOptions)
      })

    // both the parent and the child setup should be called just once
    cy.get('@parentSetup').should('be.calledOnce')
    // the parent session should be restored in memory
    // with the original timestamps, thus the child session
    // should not be recomputed
    // cy.get('@childSetup').should('be.calledOnce')
  })
})
@github-actions
Copy link

github-actions bot commented Jan 4, 2022

🎉 This issue has been resolved in version 1.15.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant