Skip to content

Instantly share code, notes, and snippets.

@jennifer-shehane
Last active October 21, 2019 14:23
Show Gist options
  • Save jennifer-shehane/2651f0704660a7450a4ff7583a542c60 to your computer and use it in GitHub Desktop.
Save jennifer-shehane/2651f0704660a7450a4ff7583a542c60 to your computer and use it in GitHub Desktop.
PR Reviews (3.5.0)
βœ… dom highlights need to account for box-sizing: border-box

cypress-io/cypress#5239

πŸ”ΆCookies CDP bug cypress-io/cypress#5297 - relies on Chrome Video Record PR

βœ… selector playground keyboard shortcuts fix cypress-io/cypress#5285

βœ… dom highlighting broken cypress-io/cypress#5299

πŸ”Άset top.onerror same as autWindow.onerror

cypress-io/cypress#5249

βœ… mouse dblclick, rightclick

mouse dblclick, rightclick

cypress-io/cypress#3030

  • There is a new .rightclick() command that allows you to right click on elements.
  • We now trigger all appropriate mouse events on .click() .dbleclick() such as mouseover, pointerdown and many others.
  • The click coordinates are now correctly printed to the console and drawn during snapshots when clicking inside an iframe element.
  • .dblclick() now accepts the same options as .click() command.
  • screenY and screenX are now sent appropriately for .trigger() command.

πŸ€“ Feedback

  • Needs a lot more comments
  • Brian is hesitant to merge and wants to look more closely at the code.
βœ… Chrome record video

Chrome record video

Dependent on cypress-io/cypress#5209

cypress-io/cypress#4628

βœ…Accept β€˜params’ to cy.visit()

βœ… cypress-io/cypress#5040

// visits to http://localhost:3500/users?page=1&role=admin

cy.visit("http://localhost:3500/users", { 
  qs: { 
    page: '1', 
    role: 'admin' 
  }
})
// visits to http://example.com/users?page=1&admins

cy.visit("http://example.com/users?page=1", { 
  qs: { 'admins' }
})
βœ…catch invalid env var

βœ… cypress-io/cypress#1626

CYPRESS_ENV=foobar cypress run

  -------
  The environment variable with the reserved name "CYPRESS_ENV" is set.
  Unset the "CYPRESS_ENV" environment variable and run Cypress again.
  ----------
  CYPRESS_ENV=foo
  ----------
  Platform: xxx
  Cypress Version: 1.2.3
  -------

πŸ€“ Feedback

  • Change the second sentence in error to 'To fix this...'
  • Actually I don't see this convention, so leaving as is.
βœ…Fix async timeouts

Fix async timeouts

cypress-io/cypress#5097

Now tests with a done callback will timeout (in defaultCommandTimeout ms) after the last cy command runs.

it('can timeout async test', function (done) {
  // times out after 4000ms
})

it('can timeout async test after cypress command', function (done) {
  cy.wait(1000)
  // times out after 5000ms
})

it('does not timeout during cypress command', function (done) {
  cy.get('.exists)
  cy.then(() => done())
  // does not time out
})

πŸ€“ Feedback

  • Move all of the tests from runner_spec.js in async timeouts to an e2e test and actually evaluate the exit code. Brian doesn't like that we are 'modifying reality' by pulling out the error then returning false.
  • Do not merge until this is changed.
βœ…err msg for detached DOM

err msg for detached DOM

cypress-io/cypress#4945

When you 'click' or do any action on an element, we now check for 'detached' before 'visibility. So the test below would fail before with just 'element was not visible', but now it will fail with 'element is detached'.

// will throw 'cy.click() failed because this element is detached from the DOM'
cy.get('input:first')
  .should(($el) => {
    $el[0].ownerDocument.addEventListener('scroll', () => {
      $el.remove()
    })
  })
  .click()

We now check that an element is attached to the DOM before checking if it is visible anywhere - this will give a more accurate error message.

cy.get('div').should('be.visible')

This element '<div>' is not visible because it is detached from the DOM

πŸ€“ Feedback

  • .should() needs to be changed as per brian's feedback.
  • MERGE IN AFTER FEEDBACK.
βœ…focus event updates

focus event updates

βœ… cypress-io/cypress#4913

Fixed a bug where Cypress was sending focus events to non-visible elements.

## normally programmatic focus calls cause "primed" focus/blur events if the window is not in focus
## so we fire fake events to act as if the window is always in focus

Elements that are hidden should not be focusable - BUT we should still send focus events on input of 0x0 size or opacity:0 because these aren't 'hidden'.

  • isFocusableAndNotHidden instead of generic isFocusable
  • parentHasDisplayNone method - since you can't figure this out on the base el like visibility: hidden can

HTML els below will no longer be force focused.

<input style="visibility:hidden" id="no-focus-1"/>
<input style="display:none" id="no-focus-2"/>
<div style="visibility:hidden"><input id="no-focus-3"/></div>
<div style="display:none"><input id="no-focus-4"/></div>

πŸ€“ Feedback

  • brian added some feedback directly to PR
  • MERGE IN AFTER FEEDBACK.
βœ…options.ensure

options.ensure

βœ… cypress-io/cypress#4881

Essentially fixes the bug where you can not click on readonly inputs.

  • Broke out checks like position to be off an object ensure, so we can write ensure.posision, ensure.notDisabled.
  • Broke out ensureReceivability into 2 checks: ensureNotReadonly & ensureNotDisabled.
βœ…--config-file

--config-file

cypress-io/cypress#3246

  • You can now pass an official --config-file flag to specify a different file to be used for Cypress configuration. You can also pass false to the --config-file to not use any configuration file.
  • File does not have to be .json, but will throw the normal JSON syntax error later on when you try to run Cypress if it contains invalid JSON.

cypress run --help

-C, --config-file <config-file>  path to JSON file where configuration values are set. defaults to "cypress.json". pass "false" to disable.

Updated all instances where we used to say 'cypress.json' to instead say your 'configuration fault' sometimes mentioning where the default is.

Errors if specified config file cannot be located and not a new project.

Could not find a Cypress configuration file, exiting.

We looked but did not find a foo.json file in this folder: path/to/folder

Does not create cypress.json on initial build of project if configFile: false.

πŸ€“ Feedback

  • Address brian's comments on the PR.
  • MERGE IN AFTER ADDRESSED.
βœ…Max viewport now 4000 instead of 3000

Max viewport now 4000 instead of 3000

βœ… cypress-io/cypress#5189

cy.viewport() width and height must be between 20px and 4000px.
βœ…Use node path from configFile

Use node path from configFile

cypress-io/cypress#4436

{
  "nodeVersion": "bundled"
}
{
  "nodeVersion": "system"
}

run stdout indicates node version

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Cypress:        1.2.3                                                                          β”‚
  β”‚ Browser:        FooBrowser 88                                                                  β”‚
  β”‚ Node Version:   v0.0.0 (bundled with Cypress)                                                  β”‚
  β”‚ Specs:          1 found (base_url_spec.coffee)                                                 β”‚
  β”‚ Searched:       cypress/integration/base_url_spec.coffee                                       β”‚
  └────────────────────────────────────────────────────────────────────────────────────────────

Errors when system NodeVersion can't be found

`nodeVersion` is set to `system`, but Cypress could not find a usable Node executable on your PATH.
Make sure that your Node executable exists and can be run by the current user.
Cypress will use the built-in Node version (v#{arg1}) instead.
βœ…Fix gzipped utf-8 .js files getting corrupted

Fix gzipped utf-8 .js files getting corrupted

cypress-io/cypress#4984

βœ…Truncate httpprops in error message to 2000 chars instead of 100

Truncate httpprops in error message to 2000 chars instead of 100

cypress-io/cypress#5150

Before

Method: GET
URL: http://localhost:2294/myreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyre...
Headers: {
  "Connection": "keep-alive",
  "user-agent": "foo",
  "accept": "*/*",
  "accept-encoding": "gzip, deflate"
}
-----------------------------------------------------------
The response we got was:
Status: 404 - Not Found
Headers: {
  "x-powered-by": "Express",
  "content-security-policy": "default-src 'self'",
  "x-content-type-options": "nosniff",
  "content-type": "text/html; charset=utf-8",
  "content-length": "301",
  "date": "Fri, 18 Aug 2017    XX:XX GMT",
  "connection": "keep-alive"
}
Body: <!DOCTYPE html>
<html lang="en">
<head>
<meta...

After

Method: GET
URL: http://localhost:2294/myreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylong
Headers: {
  "Connection": "keep-alive",
  "user-agent": "foo",
  "accept": "*/*",
  "accept-encoding": "gzip, deflate"
}
-----------------------------------------------------------
The response we got was:
Status: 404 - Not Found
Headers: {
  "x-powered-by": "Express",
  "content-security-policy": "default-src 'self'",
  "x-content-type-options": "nosniff",
  "content-type": "text/html; charset=utf-8",
  "content-length": "301",
  "date": "Fri, 18 Aug 2017    XX:XX GMT",
  "connection": "keep-alive"
}
Body: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /myreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylong</pre>
</body>
βœ…Keyboard shortcuts in the Test Runner

Keyboard shortcuts in the Test Runner

βœ… cypress-io/cypress#3943

  • pressing the R key restarts the tests
  • pressing the S key stops the tests
  • pressing F focuses the spec files window
βœ…jQuery 3.1.1

jQuery 3.1.1

βœ… cypress-io/cypress#1229

list of browsers to plugins

list of browsers to plugins

cypress-io/cypress#5068

Pass list of available browsers through plugins/index.js - with options to control its display.

module.exports = (on, config) => {
  // remove "standard" browsers and use
  // our local Electron as a browser
  config.browsers = [
    {
      name: 'electron-app',
      family: 'electron-app',
      displayName: 'Local Electron app',
      version: '1.2.3',
      path: 'foo/bar/baz/path,
      // show full package version in the browser dropdown
      majorVersion: `v${pkg.version}`,
      info: 'Electron.js app that supports the Cypress launcher'
    }
  ]

  return config
}

πŸ€“ Feedback

  • We would rather there be a method call called setBrowser or setBrowsers so that we could actually do some validation. You could mutate it and just completely mess up the launching of Cypress browser.
  • Need type definitions.
  • Do not move forward until this is change to API is made.
Add padding support to element screenshot

βœ… Add padding support to element screenshot

cypress-io/cypress#5078

// expands screenshot 10 pixels beyond boundaries of el
cy.get('.input').screenshot({ padding: 10 })

// expands screenshot -10 pixels beyond boundaries of el
cy.get('.input').screenshot({ padding: -10 })

// expands screenshot by 4 on each side, 10 on each top/bottom
cy.get('.input').screenshot({ padding: [4, 10, 4, 10] })
.screenshot() 'padding' option must be either a number or an array of numbers with a length between 1 and 4. You passed: foo

Throws if you are attempting to screenshot an element that is 0 height/width. I asked them to update wording of message to:

It was not possible to take a screenshot, since the height and/or width of the screenshot area was zero.

πŸ€“ Feedback

  • 'padding' and API is fine - move forward with making this work.
  • Needs code changes and more thorough review.
ansi_up upgrade

cypress-io/cypress#4331

reduce effect of npm silent loglevel

cypress-io/cypress#2706

βœ…Hide new NODE_TLS_REJECT_UNAUTHORIZED warning

cypress-io/cypress#5248

βœ…run driver-integration tests in electron as well

cypress-io/cypress#4987

type fixes

type fixes

cypress-io/cypress#4870

  • Requires cypress-io/cypress#3030 be merged first.
  • Can now target any focusable target with .type(), supports some weird things people should have legitimately been able to type into.
  • Using .type() in contenteditable rich text editors should now have a much better experience.
  • Throws better error message on what is 'focusable'
  • Fixed bug where Cypress was not using the correct property getter for maxLength during type validation.
Doing some refactoring from Jen's PR comments

πŸ€“ Feedback

  • Did not review
Tags for grouping

Tags for grouping

cypress-io/cypress#5164

  • Allow --tag flag to pass one or multiple tags per run

Display in --help

  tag: 'named tag(s) for recorded runs in the Cypress Dashboard',

Allow comma-separated list of tags

cypress run --tag a b c d e f g --spec h i j k l

Warn when space-separated list of tags

Warning: It looks like you're passing --tag a space-separated list of arguments:

"a b c d e f g"

This will work, but it's not recommended.

If you are trying to pass multiple arguments, separate them with commas instead:
  cypress run --tag arg1,arg2,arg3

Displays tag in run stdout

  β”‚ Browser:    FooBrowser 88                                                                      β”‚
  β”‚ Specs:      1 found (record_pass_spec.coffee)                                                  β”‚
  β”‚ Searched:   cypress/integration/record_pass*                                                   β”‚
  β”‚ Params:     Tag: nightly, Group: foo-bar, Parallel: true                                       β”‚
  β”‚ Run URL:    https://dashboard.cypress.io/#/projects/cjvoj7/runs/12                             β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Error on CI when not passing --record

You passed the --ci-build-id, --group, --tag, or --parallel flag without also passing the --record flag.

The --tag flag you passed was: nightly
The --group flag you passed was: e2e-tests

These flags can only be used when recording to the Cypress Dashboard service.

Added tag to other CI errors where we were listing params:

The --tag flag you passed was: nightly
The --group flag you passed was: electron-smoke-tests
The --ciBuildId flag you passed was: ciBuildId123

πŸ€“ Feedback

  • Did not review - want to wait for Services team work first.
Fix cy.visit() with baseUrl with .. and /

cypress-io/cypress#5175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment