From 61376ad7121ce32c0961972afb48fb051b13512b Mon Sep 17 00:00:00 2001 From: Roberto Molina <54558382+robertoms99@users.noreply.github.com> Date: Fri, 16 Dec 2022 22:56:18 -0500 Subject: [PATCH 1/4] Update variables-and-aliases.md --- content/guides/core-concepts/variables-and-aliases.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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') }) ``` From cc55a37257e8ecb694d7cb67d15ad7eda6b020ed Mon Sep 17 00:00:00 2001 From: Forest Anderson Date: Fri, 6 Jan 2023 11:19:17 -0500 Subject: [PATCH 2/4] Add missing comma in session example --- content/api/commands/session.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/api/commands/session.md b/content/api/commands/session.md index a0991bf141..09b9246ac2 100644 --- a/content/api/commands/session.md +++ b/content/api/commands/session.md @@ -339,7 +339,7 @@ const login = (name = 'user1') => { validate() { cy.visit('/user_profile') cy.contains(`Hello ${name}`) - } + }, cacheAcrossSpecs: true, }) } From a8df5037b18d8c3094d344533075c4c82d758f9e Mon Sep 17 00:00:00 2001 From: Forest Anderson Date: Fri, 6 Jan 2023 16:28:24 +0000 Subject: [PATCH 3/4] Remove `cy.` to access login function --- content/api/commands/session.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/api/commands/session.md b/content/api/commands/session.md index 09b9246ac2..f18e959642 100644 --- a/content/api/commands/session.md +++ b/content/api/commands/session.md @@ -346,12 +346,12 @@ const login = (name = 'user1') => { // profile.cy.js it('can view profile', () => { - cy.login() + login() }) // add_blog.cy.js it('can create a blog post', () => { - cy.login() + login() }) ``` From bb5b531f07b610ede756f0c51addc1803c3dc7ff Mon Sep 17 00:00:00 2001 From: Ely Lucas Date: Fri, 6 Jan 2023 10:05:46 -0700 Subject: [PATCH 4/4] chore: linting --- content/api/commands/session.md | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/content/api/commands/session.md b/content/api/commands/session.md index f18e959642..7cf7450a73 100644 --- a/content/api/commands/session.md +++ b/content/api/commands/session.md @@ -327,21 +327,25 @@ 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 @@ -353,7 +357,6 @@ it('can view profile', () => { it('can create a blog post', () => { login() }) - ``` ### Multiple login commands