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

fix: Remove error message wrapping of Cypress.Blob return values #8366

Merged
merged 2 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.