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

Support for Parameterized Tests (Similar to Pytest) #1288

Closed
marvindev2022 opened this issue Oct 28, 2024 · 3 comments
Closed

Support for Parameterized Tests (Similar to Pytest) #1288

marvindev2022 opened this issue Oct 28, 2024 · 3 comments
Labels
type: feature feature request

Comments

@marvindev2022
Copy link

Hello Cypress team and community!

I’d like to propose adding native support for parameterized tests in Cypress. This feature would allow us to run the same test logic with multiple sets of inputs and expected results, similar to parameterization features in frameworks like Pytest.

Problem

Currently, implementing parameterized tests requires custom loops or workarounds, which can make test code less readable and more verbose. Native support would simplify the process and improve readability, allowing for a more streamlined and expressive testing experience.

Proposed Solution

Adding a built-in cy.parametrize (or similar) function could:

  • Enable defining multiple test cases within a single test.
  • Simplify writing and maintaining tests with various data sets.
  • Enhance test organization by reducing duplicated code.

Benefits

  • Improves Readability: By reducing boilerplate code and making it easier to understand test cases at a glance.
  • Enhances Maintainability: Allows adding new scenarios with minimal changes to the test structure.
  • Aligns with Testing Practices: Brings Cypress in line with parameterization features found in other testing frameworks, which many developers are already familiar with.

I believe this feature would be a valuable addition to Cypress, and I’m curious to hear the community’s thoughts. Thanks for considering this idea!

@MikeMcC399 MikeMcC399 added the type: feature feature request label Oct 28, 2024
@MikeMcC399
Copy link
Collaborator

@marvindev2022

Have you considered using cy.fixture()?

This repo is probably not the right place for your suggestion, since this repo is only concerned with running Cypress under GitHub Actions. https://github.com/cypress-io/cypress is the main repository.

You can connect to the Cypress technical community on Discord

Discord chat (click on button)

@marvindev2022
Copy link
Author

Thank you for the response, @MikeMcC399 !

I’m familiar with using cy.fixture() for loading external data, but I believe that native support for parameterization would be a powerful addition to the Cypress ecosystem. The idea is to enable running the same test logic with different sets of inputs and expected results, similar to what’s available in Pytest.

This feature would not only simplify test readability and maintainability but also align Cypress with widely used testing practices, making it easier for more developers to fully leverage the platform. I’ll follow your advice and propose this idea in the main Cypress repository and also bring it up on Discord.

Thanks again for the guidance!

@MikeMcC399
Copy link
Collaborator

@marvindev2022

@MikeMcC399 MikeMcC399 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature feature request
Projects
None yet
Development

No branches or pull requests

2 participants