Skip to content

Commit

Permalink
Merge branch 'develop' into issue-7481-mappings-wasm-error
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding authored Jun 1, 2020
2 parents 9cf66db + a074302 commit e44f127
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 9 deletions.
12 changes: 10 additions & 2 deletions packages/driver/src/cypress/cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,14 @@ const create = function (specWindow, Cypress, Cookies, state, config, log) {
throw err
}

// this means the error came from a 'fail' handler, so don't send
// 'cy:fail' action again, just finish up
if (err.isCyFailErr) {
delete err.isCyFailErr

return finish(err)
}

// if we have a "fail" handler
// 1. catch any errors it throws and fail the test
// 2. otherwise swallow any errors
Expand All @@ -764,9 +772,9 @@ const create = function (specWindow, Cypress, Cookies, state, config, log) {
rets = Cypress.action('cy:fail', err, state('runnable'))
} catch (cyFailErr) {
// and if any of these throw synchronously immediately error
cyFailErr.stack = $stackUtils.normalizedStack(cyFailErr)
cyFailErr.isCyFailErr = true

return finish(cyFailErr)
return fail(cyFailErr)
}

// bail if we had callbacks attached
Expand Down
5 changes: 4 additions & 1 deletion packages/driver/src/dom/coordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ const getElementPositioning = ($el) => {
// elements that span multiple lines. Which would cause us to click
// click in the center and thus miss...
//
// sometimes the first client rect has no height or width, which also causes a miss
// so a simple loop is used to find the first with non-zero dimensions
//
// however we have a fallback to getBoundingClientRect() such as
// when the element is hidden or detached from the DOM. getClientRects()
// returns a zero length DOMRectList in that case, which becomes undefined.
// so we fallback to getBoundingClientRect() so that we get an actual DOMRect
// with all properties 0'd out
const rect = el.getClientRects()[0] || el.getBoundingClientRect()
const rect = [...el.getClientRects()].find((e) => e.width && e.height) || el.getBoundingClientRect()

// we want to return the coordinates from the autWindow to the element
// which handles a situation in which the element is inside of a nested
Expand Down
7 changes: 7 additions & 0 deletions packages/driver/test/cypress/fixtures/dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,13 @@
</p>
</div>

<div style="width: 30px; line-height: 2;">
<a href="#" id="overflow-link-width">
<i style="display: inline-block;"></i>
foofoofoofoofoo bar
</a>
</div>


<div id="massively-long-div" style="height: 500px; width: 200px; background-color: gray;"></div>
<div id="form-header-region">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,11 @@ describe('src/cy/commands/actions/click', () => {
cy.get('#overflow-link').find('.wrapped').click()
})

// https://github.com/cypress-io/cypress/issues/7343
it('can click on inline elements that wrap lines where the first rect has no width', () => {
cy.get('#overflow-link-width').click()
})

// readonly should only limit typing, not clicking
it('can click on readonly inputs', () => {
cy.get('#readonly-attr').click()
Expand Down
2 changes: 1 addition & 1 deletion packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"devDependencies": {
"chai": "3.5.0",
"cross-env": "6.0.3",
"cypress-example-kitchensink": "1.9.1",
"cypress-example-kitchensink": "1.11.0",
"gulp": "4.0.2",
"gulp-clean": "0.4.0",
"gulp-gh-pages": "0.6.0-6",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/test/e2e/8_error_ui_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const onServer = function (app) {
return app.get('/response', (req, res) => res.json({ ok: true }))
}

const VARIOUS_FAILURES_EXPECTED_FAILURES = 61
const VARIOUS_FAILURES_EXPECTED_FAILURES = 63

const verifyPassedAndFailedAreSame = (expectedFailures) => {
return ({ stdout }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,30 @@ context('event handlers', function () {
message: 'bar is not a function',
})
})

describe('fail handler assertion failure', function () {
fail(this, () => {
cy.failFailHandlerAssertion()
})

verify(this, {
column: 25,
codeFrameText: 'failFailHandlerAssertion',
message: `expected 'actual' to equal 'expected'`,
})
})

describe('fail handler exception', function () {
fail(this, () => {
cy.failFailHandlerException()
})

verify(this, {
column: 10,
codeFrameText: 'failFailHandlerException',
message: 'bar is not a function',
})
})
})

context('uncaught errors', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,36 @@ context('event handlers', function () {
message: 'bar is not a function',
})
})

describe('fail handler assertion failure', function () {
fail(this, () => {
cy.on('fail', () => {
expect('actual').to.equal('expected')
})

cy.get('#does-not-exist')
})

verify(this, {
column: 29,
message: `expected 'actual' to equal 'expected'`,
})
})

describe('fail handler exception', function () {
fail(this, () => {
cy.on('fail', () => {
({}).bar()
})

cy.get('#does-not-exist')
})

verify(this, {
column: 14,
message: 'bar is not a function',
})
})
})

context('uncaught errors', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,22 @@ Cypress.Commands.add('failEventHandlerException', () => {
cy.visit('http://localhost:1919')
})

Cypress.Commands.add('failFailHandlerAssertion', () => {
cy.on('fail', () => {
expect('actual').to.equal('expected')
})

cy.get('#does-not-exist')
})

Cypress.Commands.add('failFailHandlerException', () => {
cy.on('fail', () => {
({}).bar()
})

cy.get('#does-not-exist')
})

Cypress.Commands.add('failSyncAppException', () => {
cy.visit('/js_errors.html')
cy.get('.sync-error').click()
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9426,10 +9426,10 @@ cyclist@^1.0.1:
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=

cypress-example-kitchensink@1.9.1:
version "1.9.1"
resolved "https://registry.yarnpkg.com/cypress-example-kitchensink/-/cypress-example-kitchensink-1.9.1.tgz#dfd16a6dc95e7742ed2365527d93f0198c95b126"
integrity sha512-1lT/8H1WasgREIFYj+k/ajMZ8NXCbsI4aL462zzZxgzcBZe2F8p/7mOGMUnUIxMzwoQ7Iy+68qjreC+tYxFMIg==
cypress-example-kitchensink@1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/cypress-example-kitchensink/-/cypress-example-kitchensink-1.11.0.tgz#27c441be35ab4848803bfe5982ec4009e94939d8"
integrity sha512-D5E9H0Dys2Zgt385eDfVPaI7F/unT4VWqriYCgkKwB3rJ7g+1X/i94m12rGxTs5KZ/w/Q4SwARip8iHoS/VR6A==
dependencies:
npm-run-all "^4.1.2"
serve "11.3.0"
Expand Down

0 comments on commit e44f127

Please sign in to comment.