From f6fb8dce9940247389a9f07ce4c9aab849c7e6f6 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Wed, 24 Jun 2020 17:17:31 +0630 Subject: [PATCH 1/7] rename 'whitelist' to 'ignore' for cy.server() --- app/commands/network-requests.html | 4 ++-- app/cypress-api.html | 4 ++-- cypress/integration/examples/network_requests.spec.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/commands/network-requests.html b/app/commands/network-requests.html index b7e86552b..f7cc25b89 100644 --- a/app/commands/network-requests.html +++ b/app/commands/network-requests.html @@ -93,8 +93,8 @@

cy.server()

expect(server.enable).to.be.true // forces requests that don't match your routes to 404 expect(server.force404).to.be.false - // whitelists requests from ever being logged or stubbed - expect(server.whitelist).to.be.a('function') + // ignores requests from ever being logged or stubbed + expect(server.ignore).to.be.a('function') }) cy.server({ diff --git a/app/cypress-api.html b/app/cypress-api.html index c0b7ba3df..8696fba51 100644 --- a/app/cypress-api.html +++ b/app/cypress-api.html @@ -132,8 +132,8 @@

Cypress.S
Cypress.Server.defaults({
   delay: 0,
   force404: true,
-  whitelist: function(xhr){
-    // handle custom logic for whitelisting
+  ignore: function(xhr){
+    // handle custom logic for ignoring XHRs
   }
 })
diff --git a/cypress/integration/examples/network_requests.spec.js b/cypress/integration/examples/network_requests.spec.js index f03c7035b..ed245a2f6 100644 --- a/cypress/integration/examples/network_requests.spec.js +++ b/cypress/integration/examples/network_requests.spec.js @@ -29,8 +29,8 @@ context('Network Requests', () => { expect(server.enable).to.be.true // forces requests that don't match your routes to 404 expect(server.force404).to.be.false - // whitelists requests from ever being logged or stubbed - expect(server.whitelist).to.be.a('function') + // ignores requests from ever being logged or stubbed + expect(server.ignore).to.be.a('function') }) cy.server({ From 10aa3f89cdf4ce86b3c8bbc93f51a1d4cd5f3096 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Thu, 25 Jun 2020 14:51:17 +0630 Subject: [PATCH 2/7] Rename uses of 'whitelist' for cookies to 'preserve' --- app/cypress-api.html | 2 +- cypress/integration/examples/cypress_api.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/cypress-api.html b/app/cypress-api.html index 8696fba51..09f2730ba 100644 --- a/app/cypress-api.html +++ b/app/cypress-api.html @@ -120,7 +120,7 @@

Cypress.Co

Cypress.Cookies.default()

To set defaults for all cookies, use Cypress.Cookies.default().

Cypress.Cookies.defaults({
-  whitelist: 'session_id'
+  preserve: 'session_id'
 })
diff --git a/cypress/integration/examples/cypress_api.spec.js b/cypress/integration/examples/cypress_api.spec.js index ea64f7d4b..dab94886e 100644 --- a/cypress/integration/examples/cypress_api.spec.js +++ b/cypress/integration/examples/cypress_api.spec.js @@ -69,7 +69,7 @@ context('Cypress.Cookies', () => { // now any cookie with the name 'session_id' will // not be cleared before each new test runs Cypress.Cookies.defaults({ - whitelist: 'session_id', + preserve: 'session_id', }) }) }) From fd80a3e4c33ae598a2e6ae7f86fd13378766e3a0 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Tue, 30 Jun 2020 01:20:10 -0400 Subject: [PATCH 3/7] fix onBeforeScreenshot and onAfterScreenshot types --- cypress/integration/examples/misc.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/integration/examples/misc.spec.js b/cypress/integration/examples/misc.spec.js index 8e0c3a656..24231d799 100644 --- a/cypress/integration/examples/misc.spec.js +++ b/cypress/integration/examples/misc.spec.js @@ -89,8 +89,8 @@ context('Misc', () => { scale: false, disableTimersAndAnimations: true, screenshotOnRunFailure: true, - beforeScreenshot () { }, - afterScreenshot () { }, + onBeforeScreenshot () { }, + onAfterScreenshot () { }, }) }) }) From e68c7838e5ad9436c7fae7fef4b0d934541a11d7 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Tue, 18 Aug 2020 11:35:52 -0400 Subject: [PATCH 4/7] conditionally skip tests --- .../integration/examples/cypress_api.spec.js | 4 +++ .../examples/network_requests.spec.js | 8 ++++-- package-lock.json | 27 ++++++++++++++++--- package.json | 2 ++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/cypress/integration/examples/cypress_api.spec.js b/cypress/integration/examples/cypress_api.spec.js index 34c972379..bb4de598b 100644 --- a/cypress/integration/examples/cypress_api.spec.js +++ b/cypress/integration/examples/cypress_api.spec.js @@ -1,5 +1,7 @@ /// +const semver = require('semver') + context('Cypress.Commands', () => { beforeEach(() => { cy.visit('http://localhost:8080/cypress-api') @@ -65,6 +67,8 @@ context('Cypress.Cookies', () => { }) it('.defaults() - set defaults for all cookies', () => { + if (semver.gte(Cypress.version, '5.0.0')) return + // now any cookie with the name 'session_id' will // not be cleared before each new test runs Cypress.Cookies.defaults({ diff --git a/cypress/integration/examples/network_requests.spec.js b/cypress/integration/examples/network_requests.spec.js index 19ef33111..8695c3ce5 100644 --- a/cypress/integration/examples/network_requests.spec.js +++ b/cypress/integration/examples/network_requests.spec.js @@ -1,5 +1,7 @@ /// +const semver = require('semver') + context('Network Requests', () => { beforeEach(() => { cy.visit('http://localhost:8080/commands/network-requests') @@ -29,8 +31,10 @@ context('Network Requests', () => { expect(server.enable).to.be.true // forces requests that don't match your routes to 404 expect(server.force404).to.be.false - // ignores requests from ever being logged or stubbed - expect(server.ignore).to.be.a('function') + if (semver.lt(Cypress.version, '5.0.0')) { + // ignores requests from ever being logged or stubbed + expect(server.ignore).to.be.a('function') + } }) cy.server({ diff --git a/package-lock.json b/package-lock.json index ecd249e8f..184fdbc1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -933,6 +933,12 @@ "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", "dev": true }, + "@types/semver": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.3.tgz", + "integrity": "sha512-jQxClWFzv9IXdLdhSaTf16XI3NYe6zrEbckSpb5xhKfPbWgIyAY0AFyWWWfaiDcBuj3UHmMkCIwSRqpKMTZL2Q==", + "dev": true + }, "@types/sinonjs__fake-timers": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.1.tgz", @@ -2073,6 +2079,13 @@ "semver": "^5.5.0", "shebang-command": "^1.2.0", "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + } } }, "crypto-random-string": { @@ -5700,6 +5713,13 @@ "resolve": "^1.10.0", "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + } } }, "normalize-url": { @@ -10474,9 +10494,10 @@ } }, "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true }, "semver-compare": { "version": "1.0.0", diff --git a/package.json b/package.json index 86e8129df..3f2c0e759 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "devDependencies": { "@bahmutov/print-env": "1.2.0", "@cypress/eslint-plugin-dev": "5.0.0", + "@types/semver": "7.3.3", "colon-names": "1.0.0", "cypress": "4.12.1", "eslint": "7.0.0", @@ -76,6 +77,7 @@ "husky": "1.3.1", "netlify-plugin-cypress": "1.3.11", "semantic-release": "15.13.32", + "semver": "7.3.2", "start-server-and-test": "1.10.6", "stop-build": "1.1.0", "typescript": "3.7.4", From 31ed7817605126cd30a1f12420f16beee4b291d6 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Tue, 18 Aug 2020 11:44:56 -0400 Subject: [PATCH 5/7] ts-ignore --- cypress/integration/examples/cypress_api.spec.js | 1 + cypress/integration/examples/network_requests.spec.js | 1 + 2 files changed, 2 insertions(+) diff --git a/cypress/integration/examples/cypress_api.spec.js b/cypress/integration/examples/cypress_api.spec.js index bb4de598b..5df80c9e6 100644 --- a/cypress/integration/examples/cypress_api.spec.js +++ b/cypress/integration/examples/cypress_api.spec.js @@ -72,6 +72,7 @@ context('Cypress.Cookies', () => { // now any cookie with the name 'session_id' will // not be cleared before each new test runs Cypress.Cookies.defaults({ + // @ts-ignore preserve: 'session_id', }) }) diff --git a/cypress/integration/examples/network_requests.spec.js b/cypress/integration/examples/network_requests.spec.js index 8695c3ce5..dd933af95 100644 --- a/cypress/integration/examples/network_requests.spec.js +++ b/cypress/integration/examples/network_requests.spec.js @@ -33,6 +33,7 @@ context('Network Requests', () => { expect(server.force404).to.be.false if (semver.lt(Cypress.version, '5.0.0')) { // ignores requests from ever being logged or stubbed + // @ts-ignore expect(server.ignore).to.be.a('function') } }) From 11ed85af4f999c2a5fab5edcc8d5000be27a2239 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Tue, 18 Aug 2020 11:50:27 -0400 Subject: [PATCH 6/7] get the checks right --- cypress/integration/examples/cypress_api.spec.js | 2 +- cypress/integration/examples/network_requests.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/integration/examples/cypress_api.spec.js b/cypress/integration/examples/cypress_api.spec.js index 5df80c9e6..5c0233215 100644 --- a/cypress/integration/examples/cypress_api.spec.js +++ b/cypress/integration/examples/cypress_api.spec.js @@ -67,7 +67,7 @@ context('Cypress.Cookies', () => { }) it('.defaults() - set defaults for all cookies', () => { - if (semver.gte(Cypress.version, '5.0.0')) return + if (semver.lt(Cypress.version, '5.0.0')) return // now any cookie with the name 'session_id' will // not be cleared before each new test runs diff --git a/cypress/integration/examples/network_requests.spec.js b/cypress/integration/examples/network_requests.spec.js index dd933af95..8379191d4 100644 --- a/cypress/integration/examples/network_requests.spec.js +++ b/cypress/integration/examples/network_requests.spec.js @@ -31,7 +31,7 @@ context('Network Requests', () => { expect(server.enable).to.be.true // forces requests that don't match your routes to 404 expect(server.force404).to.be.false - if (semver.lt(Cypress.version, '5.0.0')) { + if (semver.gte(Cypress.version, '5.0.0')) { // ignores requests from ever being logged or stubbed // @ts-ignore expect(server.ignore).to.be.a('function') From 63f3dd28989534af0c8ae89bc454a8400453e125 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Tue, 18 Aug 2020 12:31:19 -0400 Subject: [PATCH 7/7] remove need for semver dep --- cypress/integration/examples/cypress_api.spec.js | 4 +--- .../integration/examples/network_requests.spec.js | 5 ++--- package-lock.json | 12 ------------ package.json | 2 -- 4 files changed, 3 insertions(+), 20 deletions(-) diff --git a/cypress/integration/examples/cypress_api.spec.js b/cypress/integration/examples/cypress_api.spec.js index 5c0233215..94f5dcc2a 100644 --- a/cypress/integration/examples/cypress_api.spec.js +++ b/cypress/integration/examples/cypress_api.spec.js @@ -1,7 +1,5 @@ /// -const semver = require('semver') - context('Cypress.Commands', () => { beforeEach(() => { cy.visit('http://localhost:8080/cypress-api') @@ -67,7 +65,7 @@ context('Cypress.Cookies', () => { }) it('.defaults() - set defaults for all cookies', () => { - if (semver.lt(Cypress.version, '5.0.0')) return + if (Number(Cypress.version.charAt(0)) < 5) return // now any cookie with the name 'session_id' will // not be cleared before each new test runs diff --git a/cypress/integration/examples/network_requests.spec.js b/cypress/integration/examples/network_requests.spec.js index 8379191d4..4d92d7fc3 100644 --- a/cypress/integration/examples/network_requests.spec.js +++ b/cypress/integration/examples/network_requests.spec.js @@ -1,7 +1,5 @@ /// -const semver = require('semver') - context('Network Requests', () => { beforeEach(() => { cy.visit('http://localhost:8080/commands/network-requests') @@ -31,7 +29,8 @@ context('Network Requests', () => { expect(server.enable).to.be.true // forces requests that don't match your routes to 404 expect(server.force404).to.be.false - if (semver.gte(Cypress.version, '5.0.0')) { + + if (Number(Cypress.version.charAt(0)) >= 5) { // ignores requests from ever being logged or stubbed // @ts-ignore expect(server.ignore).to.be.a('function') diff --git a/package-lock.json b/package-lock.json index 184fdbc1e..5d3e1eb83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -933,12 +933,6 @@ "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", "dev": true }, - "@types/semver": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.3.tgz", - "integrity": "sha512-jQxClWFzv9IXdLdhSaTf16XI3NYe6zrEbckSpb5xhKfPbWgIyAY0AFyWWWfaiDcBuj3UHmMkCIwSRqpKMTZL2Q==", - "dev": true - }, "@types/sinonjs__fake-timers": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.1.tgz", @@ -10493,12 +10487,6 @@ } } }, - "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true - }, "semver-compare": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", diff --git a/package.json b/package.json index 3f2c0e759..86e8129df 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,6 @@ "devDependencies": { "@bahmutov/print-env": "1.2.0", "@cypress/eslint-plugin-dev": "5.0.0", - "@types/semver": "7.3.3", "colon-names": "1.0.0", "cypress": "4.12.1", "eslint": "7.0.0", @@ -77,7 +76,6 @@ "husky": "1.3.1", "netlify-plugin-cypress": "1.3.11", "semantic-release": "15.13.32", - "semver": "7.3.2", "start-server-and-test": "1.10.6", "stop-build": "1.1.0", "typescript": "3.7.4",