diff --git a/content/api/commands/session.md b/content/api/commands/session.md index a0991bf141..7cf7450a73 100644 --- a/content/api/commands/session.md +++ b/content/api/commands/session.md @@ -327,33 +327,36 @@ leverage the session through the run. ```js const login = (name = 'user1') => { - cy.session(name, () => { - cy.request({ - method: 'POST', - url: '/login', - body: { name, password: 's3cr3t' }, - }).then(({ body }) => { - window.localStorage.setItem('authToken', body.token) - }) - }, { - validate() { + cy.session( + name, + () => { + cy.request({ + method: 'POST', + url: '/login', + body: { name, password: 's3cr3t' }, + }).then(({ body }) => { + window.localStorage.setItem('authToken', body.token) + }) + }, + { + validate() { cy.visit('/user_profile') cy.contains(`Hello ${name}`) + }, + cacheAcrossSpecs: true, } - cacheAcrossSpecs: true, - }) + ) } // profile.cy.js it('can view profile', () => { - cy.login() + login() }) // add_blog.cy.js it('can create a blog post', () => { - cy.login() + login() }) - ``` ### Multiple login commands diff --git a/content/guides/core-concepts/variables-and-aliases.md b/content/guides/core-concepts/variables-and-aliases.md index 7188bfbba4..5a237bf9ce 100644 --- a/content/guides/core-concepts/variables-and-aliases.md +++ b/content/guides/core-concepts/variables-and-aliases.md @@ -430,9 +430,9 @@ cy.then(function () { }) cy.get('@favoriteColor').then(function (aliasValue) { - expect(aliasColor).to.eql('red') + expect(aliasValue).to.eql('red') - expect(this.color).to.eql('blue') + expect(this.favoriteColor).to.eql('blue') }) ```