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

Cypress Studio experimental version docs #3394

Merged
merged 20 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions source/_data/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ guides:
variables-and-aliases: variables-and-aliases.html
conditional-testing: conditional-testing.html
test-runner: test-runner.html
cypress-studio: cypress-studio.html
dashboard:
dashboard-introduction: introduction.html
projects: projects.html
Expand Down
96 changes: 96 additions & 0 deletions source/guides/core-concepts/cypress-studio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
title: Cypress Studio
---

{% note info %}
# {% fa fa-graduation-cap %} What you'll learn

- How to extend tests interactively using the Cypress Studio
{% endnote %}

# Overview

Cypress Studio provides a visual way to generate tests within the Test Runner, by *recording interactions* against the application under test.


{% imgTag /img/guides/cypress-studio/cypress-studio-overview.png "Cypress Studio" "no-border" %}

## Using Cypress Studio

The Cypress {% fa fa-github %} {% url "Real World App (RWA)" https://github.com/cypress-io/cypress-realworld-app %} will be use to demo the functionality of Cypress Studio.
kevinold marked this conversation as resolved.
Show resolved Hide resolved

### Extending a Test
kevinold marked this conversation as resolved.
Show resolved Hide resolved

Create a file under `cypress/integration` with the following test scaffolding.
kevinold marked this conversation as resolved.
Show resolved Hide resolved

```js
describe('Cypress Studio Demo', function () {
beforeEach(function () {
// Seed database with test data
cy.task('db:seed')

// Login test user
cy.database('find', 'users').then((user) => {
cy.login(user.username, 's3cret', true)
})
Comment on lines +41 to +46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would discourage against having code here that can't be copy/pasted and work with no other code in their project. People will copy/paste this and get an error like 'cy.database is not defined' and 'cy.login is not defined' and be confused.

})

it('create new transaction', function () {
// Extend test with Cypress Studio
})

it('create new bank account', function () {
// Extend test with Cypress Studio
})
})
```

We will use Cypress Studio to perform a New Transaction user journey.

We are logged into the application inside the `beforeEach` block.

Cypress Studio is directly integrated with the {% url 'Command Log' test-runner#Command-Log %}.

First, launch the Test Runner and run the spec created in the previous step.

{% imgTag /img/guides/cypress-studio/extend-test-1.png "Cypress Studio" "no-border" %}

Once the tests complete the run, hovering over the test in the Command Log will reveal an "Extend Test" button. Clicking on "Extend Test" will launch the Cypress Studio.

{% imgTag /img/guides/cypress-studio/extend-test-2.png "Cypress Studio" "no-border" %}

Click the "Get Started" button to begin interacting with your site to generate tests.
{% imgTag /img/guides/cypress-studio/extend-test-3.png "Cypress Studio Get Started" "no-border" %}

Next, the Test Runner will execute the test in isolation and pause after the last command in the test.
kevinold marked this conversation as resolved.
Show resolved Hide resolved
{% imgTag /img/guides/cypress-studio/extend-test-4.png "Cypress Studio Extend Test" "no-border" %}

Now, we can begin updating the test to create a new transaction between users.

To record actions, begin interacting with the application. Here we will click on the first name input and as a result we will see the click recorded in the Command Log.

{% imgTag /img/guides/cypress-studio/extend-test-5.png "Cypress Studio Extend Test" "no-border" %}

Next, we can type the name of a user to pay and click on the user in the results.

{% imgTag /img/guides/cypress-studio/extend-test-6.png "Cypress Studio Extend Test" "no-border" %}


Next, we will complete the transaction form clicking on and typing in the amount and description inputs. Notice the commands generated in the command log.
{% imgTag /img/guides/cypress-studio/extend-test-7.png "Cypress Studio Extend Test" "no-border" %}


Finally, we will click the "Pay" button.
{% imgTag /img/guides/cypress-studio/extend-test-8.png "Cypress Studio Extend Test" "no-border" %}

We are presented with a confirmation page of our new transaction.
{% imgTag /img/guides/cypress-studio/extend-test-9.png "Cypress Studio Extend Test Confirmation" "no-border" %}

## Supported Commands
kevinold marked this conversation as resolved.
Show resolved Hide resolved

The following Cypress commands are supported. Test code will be generated when interacting with the DOM inside of the Cypress Studio:

- {% url `.click()` click %}
- {% url `.dblclick()` dblclick %}
- {% url `.type()` type %}
- {% url `.select()` select %}
1 change: 1 addition & 0 deletions themes/cypress/languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ sidebar:
writing-and-organizing-tests: Writing and Organizing Tests
conditional-testing: Conditional Testing
test-runner: The Test Runner
cypress-studio: Cypress Studio
dashboard: Dashboard
dashboard-introduction: Introduction
projects: Projects
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.