Skip to content

Commit

Permalink
fix: Remove error message wrapping of Cypress.Blob return values (#8366)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding authored Aug 20, 2020
1 parent d5ed26b commit 1fb7a88
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 98 deletions.
32 changes: 32 additions & 0 deletions packages/driver/cypress/integration/util/blob_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
describe('blob-util 2.x', () => {
const { Blob, Promise } = Cypress

// https://github.com/cypress-io/cypress/issues/8365
;[
['arrayBufferToBlob', '1234'],
['base64StringToBlob', '1234'],
['binaryStringToBlob', '0100101'],
['dataURLToBlob', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='],
].forEach(([method, value]) => {
it(`Cypress.Blob.${method} does not error when wrapped by Promise methods`, () => {
return Promise.all([
Promise.resolve(Blob[method](value)),
Promise.try(() => Blob[method](value)),
])
})

it(`Cypress.Blob.${method} does not error with 5.0.0 workaround`, () => {
// this is the 5.0.0 workaround that the cypress-file-upload plugin uses
const wrapBlob = (blob) => {
delete blob.then

return Cypress.Promise.resolve(blob)
}

return Promise.all([
Promise.resolve(wrapBlob(Blob[method](value))),
Promise.try(() => wrapBlob(Blob[method](value))),
])
})
})
})

This file was deleted.

3 changes: 1 addition & 2 deletions packages/driver/src/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const $scriptUtils = require('./cypress/script_utils')
const browserInfo = require('./cypress/browser')
const resolvers = require('./cypress/resolvers')
const debug = require('debug')('cypress:driver:cypress')
const { wrapBlobUtil } = require('./util/breaking_change_warning')

const jqueryProxyFn = function (...args) {
if (!this.cy) {
Expand Down Expand Up @@ -646,7 +645,7 @@ $Cypress.prototype.SelectorPlayground = $SelectorPlayground
$Cypress.prototype.utils = $utils
$Cypress.prototype._ = _
$Cypress.prototype.moment = moment
$Cypress.prototype.Blob = wrapBlobUtil(blobUtil)
$Cypress.prototype.Blob = blobUtil
$Cypress.prototype.Promise = Promise
$Cypress.prototype.minimatch = minimatch
$Cypress.prototype.sinon = sinon
Expand Down
25 changes: 8 additions & 17 deletions packages/driver/src/cypress/error_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,6 @@ module.exports = {
},
},

breaking_change: {
blob_util2 (obj) {
return {
message: `\`${obj.functionName}()\` no longer returns a \`Promise\`. Update the use of \`${obj.functionName}()\` to expect a returned \`Blob\`.`,
docsUrl: 'https://on.cypress.io/migration-guide',
}
},
},

browser: {
invalid_arg: '{{prefix}} must be passed a string, object, or an array. You passed: `{{obj}}`',
},
Expand Down Expand Up @@ -385,9 +376,9 @@ module.exports = {
not_scrollable: {
message: stripIndent`\
${cmd('{{cmd}}')} failed because this element is not scrollable:
\`{{node}}\`
Make sure you're targeting the correct element or use \`{ensureScrollable: false}\` to disable the scrollable check.`,
docsUrl: 'https://on.cypress.io/scrollto',
},
Expand Down Expand Up @@ -893,8 +884,8 @@ module.exports = {
it('{{title}}', { retries: {{numRetries}} }, () => {
...
})
\`\`\`
\`\`\`
https://on.cypress.io/test-retries
`,
manually_set_retries_suite: stripIndent`\
Expand All @@ -906,8 +897,8 @@ module.exports = {
describe('{{title}}', { retries: {{numRetries}} }, () => {
...
})
\`\`\`
\`\`\`
https://on.cypress.io/test-retries
`,

Expand Down Expand Up @@ -1856,9 +1847,9 @@ module.exports = {
timed_out: {
message: stripIndent`
${cmd('wrap')} timed out waiting \`{{timeout}}ms\` to complete.
You called \`cy.wrap()\` with a promise that never resolved.
To increase the timeout, use \`{ timeout: number }\`
`,
docsUrl: 'https://on.cypress.io/wrap',
Expand Down
34 changes: 0 additions & 34 deletions packages/driver/src/util/breaking_change_warning.ts

This file was deleted.

3 comments on commit 1fb7a88

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1fb7a88 Aug 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/linux-x64/circle-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-428102/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/circle-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-428023/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1fb7a88 Aug 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-ia32/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 1fb7a88 Aug 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.1/win32-x64/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.1/appveyor-develop-1fb7a880cbbd5d8207e09f4b5f1d3f51587b6411-34766979/cypress.tgz

Please sign in to comment.