Skip to content

Commit

Permalink
Improves not-valid code warnings (cypress-io#2649)
Browse files Browse the repository at this point in the history
* Improves not-valid code warnings

Makes them more explicit and also puts some of them into the code sample (the only thing many people actually read)

* make warning even more obvious + fix weird formatting?

Co-authored-by: Jennifer Shehane <[email protected]>
  • Loading branch information
JoeSchr and jennifer-shehane authored Mar 23, 2020
1 parent 1ba710f commit b5d018e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions source/guides/core-concepts/conditional-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,13 @@ However, this is really the same question as asking to do conditional testing, b

For instance you may want to do this:

**The following code is not valid, you cannot add error handling to Cypress commands. The code is just for demonstration purposes.**
{% note danger %}
{% fa fa-exclamation-triangle red %} The following code is not valid.
{% endnote %}

```js
//! You cannot add error handling to Cypress commands
//! This code is just for demonstration purposes
cy.get('button').contains('hello')
.catch((err) => {
// oh no the button wasn't found
Expand All @@ -408,10 +412,13 @@ Enabling this would mean that for every single command, it would recover from er

Let's reimagine our "Welcome Wizard" example from before.

**The following code is not valid, you cannot add error handling to Cypress commands. The code is just for demonstration purposes.**
{% note danger %}
{% fa fa-exclamation-triangle red %} The following code is not valid.
{% endnote %}

```js
// great error recovery code
//! You cannot add error handling to Cypress commands.
//! This code is just for demonstration purposes
function keepCalmAndCarryOn () {
cy.get(...).should(...).click()
}
Expand Down

0 comments on commit b5d018e

Please sign in to comment.