Skip to content

Commit

Permalink
Merge branch 'develop' into config/62-add-plugin-pr-template
Browse files Browse the repository at this point in the history
  • Loading branch information
bencodezen committed May 28, 2020
2 parents bb2c2a7 + 6e4ec3b commit 66bd684
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 82 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const revisionOpts = {
dontRenameFile: ['.html', 'CNAME'],
dontUpdateReference: ['.html'],
dontSearchFile: ['.js'],
debug: process.env.NODE_ENV === 'production',
debug: true,
}

function remove (folder) {
Expand Down
84 changes: 8 additions & 76 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"cheerio": "1.0.0-rc.3",
"coffee-react": "5.0.1",
"common-tags": "1.8.0",
"cypress": "4.5.0",
"cypress": "4.7.0",
"dependency-check": "3.4.1",
"deps-ok": "1.4.1",
"eslint": "6.1.0",
Expand Down
16 changes: 16 additions & 0 deletions source/_changelogs/4.7.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 4.7.0

*Released 5/26/2020*

**Features:**

- {% url "`cy.request()`" request %} now supports an `encoding` option that can be used to set the encoding of the response body, defaulting to `utf-8`. Addresses {% issue 2029 %} and {% issue 3576 %}.

**Bugfixes:**

- We fixed a regression in {% url "4.6.0" changelog-4-6-0 %} where the address bar of the application under test would disappear when scrolling commands ran and the application under test would visually shift after taking screenshots. Fixes {% issue 7443 %} and {% issue 7466 %}.
- We fixed a regression in {% url "4.6.0" changelog-4-6-0 %} where test runs could hang when loading spec files with source maps. Fixes {% issue 7464 %}.

**Misc:**

- We now display a more descriptive error message when the plugins file does not export a function. Addresses {% issue 6611 %}.
1 change: 1 addition & 0 deletions source/_data/courses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
sourceUrl: https://www.pluralsight.com/courses/cypress-end-to-end-javascript-testing

- title: "Add e2e tests with cypress to a React application"
url: https://egghead.io/playlists/add-e2e-tests-with-cypress-to-a-react-application-7691?af=6p5abz
author: Tomasz Łakomy
authorTwitter: tlakomy
sourceName: egghead.io
Expand Down
5 changes: 5 additions & 0 deletions source/_data/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@
link: https://github.com/mfrachet/cypress-audit
keywords: [lighthouse]

- name: cypress-hmr-restarter
description: Restarts tests when receiving webpack-dev-server HMR updates
link: https://github.com/Svish/cypress-hmr-restarter
keywords: [webpack, webpack-dev-server, hmr]

- name: Custom Commands
plugins:
- name: cy-view
Expand Down
35 changes: 34 additions & 1 deletion source/api/commands/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cy.request('seed/admin') // url is http://localhost:1234/seed/admin

**{% fa fa-angle-right %} body** ***(String, Object)***

A request `body` to be sent in the request. Cypress sets the `Accepts` request header and serializes the response body by its `Content-Type`.
A request `body` to be sent in the request. Cypress sets the `Accepts` request header and serializes the response body by the `encoding` option.

**{% fa fa-angle-right %} method** ***(String)***

Expand Down Expand Up @@ -103,6 +103,7 @@ Option | Default | Description
`failOnStatusCode` | `true` | Whether to fail on response codes other than `2xx` and `3xx`
`followRedirect` | `true` | Whether to automatically follow redirects
`form` | `false` | Whether to convert the `body` values to url encoded content and set the `x-www-form-urlencoded` header
`encoding` | `utf8` | The encoding to be used when serializing the response body. The following encodings are supported: `ascii`, `base64`, `binary`, `hex`, `latin1`, `utf8`, `utf-8`, `ucs2`, `ucs-2`, `utf16le`, `utf-16le`
`gzip` | `true` | Whether to accept the `gzip` encoding
`headers` | `null` | Additional headers to send; Accepts object literal
`qs` | `null` | Query parameters to append to the `url` of the request
Expand Down Expand Up @@ -196,6 +197,37 @@ cy.request({
})
```

### Download a PDF file

By passing the `encoding: binary` option, the `response.body` will be serialized binary content of the file. You can use this to access various file types via `.request()` like `.pdf`, `.zip`, or `.doc` files.

```javascript
cy.request({
url: 'http://localhost:8080/some-document.pdf',
encoding: 'binary',
})
.then((response) => {
cy.writeFile('path/to/save/document.pdf', response.body, 'binary')
})
```

### Get Data URL of an image

By passing the `encoding: base64` option, the `response.body` will be base64-encoded content of the image. You can use this to construct a {% url "Data URI" https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs %} for use elsewhere.

```javascript
cy.request({
url: 'https://docs.cypress.io/img/logo.png',
encoding: 'base64',
})
.then((response) => {
const base64Content = response.body
const mime = response.headers['content-type'] // or 'image/png'
// see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
const imageDataUrl = `data:${mime};base64,${base64Content}`
})
```

### HTML form submissions using form option

Oftentimes, once you have a proper e2e test around logging in, there's no reason to continue to `cy.visit()` the login and wait for the entire page to load all associated resources before running any other commands. Doing so can slow down our entire test suite.
Expand Down Expand Up @@ -329,6 +361,7 @@ When clicking on `request` within the command log, the console outputs the follo
{% imgTag /img/api/request/console-log-request-response-body-headers-status-url.png "Console Log request" %}

{% history %}
{% url "4.7.0" changelog#3-3-0 %} | Added support for `encoding` option.
{% url "3.3.0" changelog#3-3-0 %} | Added support for options `retryOnStatusCodeFailure` and `retryOnNetworkFailure`.
{% url "3.2.0" changelog#3-2-0 %} | Added support for any valid HTTP `method` argument including `TRACE`, `COPY`, `LOCK`, `MKCOL`, `MOVE`, `PURGE`, `PROPFIND`, `PROPPATCH`, `UNLOCK`, `REPORT`, `MKACTIVITY`, `CHECKOUT`, `MERGE`, `M-SEARCH`, `NOTIFY`, `SUBSCRIBE`, `UNSUBSCRIBE`, `SEARCH`, and `CONNECT`.
{% endhistory %}
Expand Down
4 changes: 2 additions & 2 deletions source/guides/references/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Our team is always planning and working on really "big" upcoming features. Prior

## Test Runner

*Last updated Apr 29, 2020*
*Last updated May 25, 2020*

Status | Feature | Issue | PR | Released
---------------------| -----------------------------------|-------------------|--------------|------------
*Experimental* | **Component Testing** | {% issue 5922 %} | {% PR 5923 %}| {% url "v4.5.0" changelog#4-5-0 %}
*Work in progress* | **Improve Test Runner errors** | {% issue 3762 %} | {% PR 3930 %}|
*Done* | **Improve Test Runner errors** | {% issue 3762 %} | {% PR 3930 %}| {% url "v4.6.0" changelog#4-6-0 %}
*Work in progress* | **Test retries** | {% issue 1313 %} | {% PR 3968 %}|
*Work in progress* | **Full network layer stubbing** | {% issue 687 %} | {% PR 4176 %}|

Expand Down
44 changes: 43 additions & 1 deletion source/guides/tooling/code-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ To handle code coverage collected during each test, we created a {% url "`@cypre

## Install the plugin

{% note info %}
Please consult the {% url "`@cypress/code-coverage`" https://github.com/cypress-io/code-coverage %} documentation for up-to-date installation instructions.
{% endnote %}

```shell
npm install -D @cypress/code-coverage nyc istanbul-lib-coverage
npm install -D @cypress/code-coverage
```

Then add the code below to your {% url "`supportFile`" configuration#Folders-Files %} and {% url "`pluginsFile`" configuration#Folders-Files %}.
Expand All @@ -210,7 +214,10 @@ import '@cypress/code-coverage/support'
// cypress/plugins/index.js
module.exports = (on, config) => {
require('@cypress/code-coverage/task')(on, config)
// include any other plugin code...

// It's IMPORTANT to return the config object
// with any changed environment variables
return config
}
```
Expand Down Expand Up @@ -446,6 +453,39 @@ We are currently exploring two additional features for code coverage during end-

Second, we would like to capture the code coverage from *the locally running back end server* that is serving the front end web application and handles the API requests from the web application under test. We believe that E2E tests with additional {% url "API tests" https://www.cypress.io/blog/2017/11/07/add-gui-to-your-e2e-api-tests/ %} that Cypress can perform can effectively cover a lot of back end code.

# Videos

There is a series of videos we have recorded showing code coverage in Cypress

### How to instrument react-scripts web application for code coverage
<!-- textlint-disable terminology -->
{% video youtube edgeQZ8UpD0 %}

### Get code coverage reports from Cypress tests

{% video youtube y8StkffYra0 %}

### Excluding code from code coverage reports

{% video youtube DlceMpRpbAw %}

### Check code coverage robustly using 3rd party tool

{% video youtube dwU5gUG2 %}

### Adding code coverage badge to your project

{% video youtube bNVRxb-MKGo %}

### Show code coverage in commit status check

{% video youtube AAl4HmJ3YuM %}

### Checking code coverage on pull request

{% video youtube 9Eq_gIshK0o %}
<!-- textlint-enable -->

# Examples

You can find full examples showing different code coverage setups in the following repositories:
Expand All @@ -469,3 +509,5 @@ Find the full list of examples linked in {% url cypress-io/code-coverage#externa
- {% url "Combined End-to-end and Unit Test Coverage" https://glebbahmutov.com/blog/combined-end-to-end-and-unit-test-coverage/ %}
- {% url "Code Coverage by Parcel Bundler" https://glebbahmutov.com/blog/code-coverage-by-parcel/ %}
- {% url "Code Coverage for End-to-end Tests" https://glebbahmutov.com/blog/code-coverage-for-e2e-tests/ %}


0 comments on commit 66bd684

Please sign in to comment.