Is there a code generator for Cypress testing tool [closed]
Asked Answered
L

7

14

I have been studying Cypress testing tool. I have huge front end flow to test . Writing so much JS code will be tough .

So i want to know if there is a code generator that records/generates code tests.

I know a tool Snaptest - snaptest.io . However this tool generates code in NightWatchJS and Chromeless only . the Cypress framework is disabled .

i found this - https://github.com/cypress-io/generator-node-cypress But i am not sure what this does .

So i want to know if there is any alternate recorder/generator for generating code to use in Cypress .

Suggestions ? Thanks .

Linkoski answered 29/8, 2018 at 8:47 Comment(1)
Not exactly what you're looking for, but I recently wrote a library to simplify writing common actions (clicking, typing, etc) in Cucumber. So for example you would just have to write "I click on the "Submit Button"" and it would click on the submit button. Check it out: picklejs.comUltracentrifuge
N
6

2021 Update

There have been generators available for a while that the other answers mention. I originally answered this in August 2018, at which time there were no generators available. I still stand by my advice below.

Original answer

To answer your question:

No

To provide you unsolicited advice:

Testing a huge flow throughout your front end is an anti-pattern in Cypress. They (and I) recommend breaking that up into a spec for each page, then only add small tests to that spec for the actions that you perform on that page. You will also want to mock, stub, or otherwise programmatically set up and tear down the required state for that spec to run.

See this page and watch the linked YouTube video to get a better idea. https://docs.cypress.io/guides/references/best-practices.html#Organizing-Tests-Logging-In-Controlling-State

I have a long history of using selenium with page objects and workflows. I fought this idea for a while when I started using Cypress but have drank the kool-aid and find it is MUCH better this way.

Nekton answered 29/8, 2018 at 14:33 Comment(3)
That helped . but what does this do - github.com/cypress-io/generator-node-cypress ?Linkoski
or is it possible to add nightwatchJS code in cypress js file ?Linkoski
@Linkoski The repo you linked appears to be for generating the NPM package for Cypress. You will not be able to add Nightwatch code to Cypress, as they work in completely different ways; for one, Nightwatch uses the W3C Webdriver API, while Cypress runs in the browser and uses its own web driver when it needs to.Loup
W
10

Yes, it looks like there is a good attempt to create a scenario recorder and it works to a great extent:

https://chrome.google.com/webstore/detail/cypress-scenario-recorder/fmpgoobcionmfneadjapdabmjfkmfekb/related?hl=en

Whitsunday answered 26/3, 2019 at 12:50 Comment(1)
The QA team at my company have been using Cypress Scenario Recorder for a year. It saves a LOT of time. chrome.google.com/webstore/detail/cypress-scenario-recorder/…Poetry
N
6

2021 Update

There have been generators available for a while that the other answers mention. I originally answered this in August 2018, at which time there were no generators available. I still stand by my advice below.

Original answer

To answer your question:

No

To provide you unsolicited advice:

Testing a huge flow throughout your front end is an anti-pattern in Cypress. They (and I) recommend breaking that up into a spec for each page, then only add small tests to that spec for the actions that you perform on that page. You will also want to mock, stub, or otherwise programmatically set up and tear down the required state for that spec to run.

See this page and watch the linked YouTube video to get a better idea. https://docs.cypress.io/guides/references/best-practices.html#Organizing-Tests-Logging-In-Controlling-State

I have a long history of using selenium with page objects and workflows. I fought this idea for a while when I started using Cypress but have drank the kool-aid and find it is MUCH better this way.

Nekton answered 29/8, 2018 at 14:33 Comment(3)
That helped . but what does this do - github.com/cypress-io/generator-node-cypress ?Linkoski
or is it possible to add nightwatchJS code in cypress js file ?Linkoski
@Linkoski The repo you linked appears to be for generating the NPM package for Cypress. You will not be able to add Nightwatch code to Cypress, as they work in completely different ways; for one, Nightwatch uses the W3C Webdriver API, while Cypress runs in the browser and uses its own web driver when it needs to.Loup
J
4

There is a built-in recorder inside the Cypress Support Pro plugin for IntelliJ platform (IDEA, Webstorm etc.) It allows recording UI action inside the Cypress Runner and insert the generated code directly to your case in IDE. Also, recorder has pluggable architecture that make it easy to extend or replace code-generation logic. By default, it uses the scripts from KabaLabs / Cypress-Recorder.

Here is a brief video overview of recorder: https://www.youtube.com/watch?v=FgnHYwmguFI You can try plugin for free here: https://plugins.jetbrains.com/plugin/13987-cypress-support-pro (or just install it via settings -> plugins menu in IDE)

Self-promotion disclosure: I'm the author of this paid plugin.

Justifier answered 30/6, 2020 at 17:8 Comment(0)
L
3

There is a new Cypress Recorder extension (different from the one posted above) that we have created that we feel may be closer to what you are asking for than the previously posted one above.

https://chrome.google.com/webstore/detail/cypress-recorder/glcapdcacdfkokcmicllhcjigeodacab

Please feel free to let us know what you think.

Ludwigg answered 31/10, 2019 at 13:17 Comment(0)
L
2

According to this issue on Github, a test recorder has been proposed but is not currently a feature in Cypress.

Loup answered 29/8, 2018 at 12:7 Comment(0)
F
1

"Cypress Studio provides a visual way to generate tests within the Test Runner, by recording interactions against the application under test." https://docs.cypress.io/guides/core-concepts/cypress-studio

Flotation answered 10/8, 2021 at 21:0 Comment(0)
C
1

I know it's a little late but.

I just saw Preflight's Cypress recorder and it works like a magic creates perfect css selectors and adapts to ui changes (updates the script automatically), it even creates email testing scripts automatically.

https://cypress.preflight.com

In my personal opinion it's way better than Katalon

Chlorophyll answered 23/3, 2022 at 15:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.