question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to run each test several times ?

See original GitHub issue

Hello !

We’re writing our tests mobile-first with cypress-cucumber-preprocessor. By default, all the tests are run with a mobile viewport. But on some specific cases, we want to run them on desktop viewport.

This is possible since this PR : https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/pull/216. We’re just using the Before to adapt the viewport depending on tags :

Before({ tags: '@desktop' }, () => {
  cy.viewport(desktopWidth, desktopHeight);
});

This is doing the job, but now we would like to enable the tests on both desktop and mobile viewports. Some tests are not mobile or desktop only, we want to run them on both viewports. So we will have three cases of tests :

  • Mobile only => the test is not tagged
  • Desktop only => the test is tagged with @desktop
  • Mobile AND Desktop => the test is tagged with @all-viewport

We could implement this duplicating the tests by ourself (writing the wanted tests two times, with a different tag on each), but we’re looking for a better way (and easier to maintain).

Do someone know if it’s possible to implement this with the plugin ? Or natively with Cypress ? @jcundill any idea ? 😏

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
avelainecommented, Mar 12, 2020

If you only have few scenarios that you want to try in different viewports, then you can create a Scenario Outline with a table of your different viewports. It will run your scenario with as many arguments as you got. 🙂 Hope it can help !

Example:

Scenario Outline: Display a button on <size>
    Given I am on the <size> viewport
    Then a button should be displayed

    Examples:
      | size       |
      | mobile   |
      | desktop |
0reactions
badeballcommented, Apr 10, 2022

Due to personal reasons, the previous maintainers of this package are stepping down and handing the reigns over to me, a long-time contributor to the project and a user of it myself. This is a responsibility I’m very excited about. Furthermore, I’d like to thank @lgandecki ++ for all the work that they’ve done so far.

Read more about the transfer of ownership here.

The repository has however moved and all outstanding issues are being closed. This is not a reflection of the perceived importance of your reported issue. However, if after upgrading to the new version, you still find there to be an issue, feel free to open up another ticket or comment below. Please make sure to read CONTRIBUTING.md before doing so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running test multiple times with different parameters
First of all, you need to annotate your test class to run with the `Parametized` runner. Next, is your test method. Initially, I...
Read more >
java - Easy way of running the same junit test over and over?
The easiest (as in least amount of new code required) way to do this is to run the test as a parametrized test...
Read more >
How To Run Same Test Multiple Times In Selenium ... - Inviul
First, create a TestNG class file and add all the required annotations. Identify that @Test annotation which you want to run multiple times....
Read more >
In Playwright Test is there an easy way to loop the test multiple ...
In Playwright Test is there an easy way to loop the test multiple times to ... This command will run all tests within...
Read more >
How to run a test multiple times with Cypress to prove it is stable
Today you will learn how to ensure that your tests behave the same way when run multiple times. Cypress.io is a fantastic testing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found