Rayrun
← Back to Discord Forum

Creating dynamic tests based on a response from a request.

fellogen_77366posted in #help-playwright
Open in Discord
fellogen_77366

Up until now, I've found it impossible to create tests purely based on a response from an endpoint. My goal is to hit an endpoint, and based on its response, perform subsequent tests.

For example, suppose I get a response in a "before" step that contains 150 URLs. I would like to create a test for an array of those URLs, such as using array.forEach(). However, this approach seems to result in the framework (be it Cypress or any other) not recognizing the tests.

So, in essence, is there a way to create tests if we don't know in advance how many tests there will be?

I do have a workaround for this: I perform the main request, get the response with the 150 URLs, and within the same test, I make requests and checks for each of these URLs. This approach works in both Cypress and Playwright, but I can't split them into individual tests or "it" blocks (in the case of Cypress).

This thread is trying to answer question "Is there a way to create tests if we don't know in advance how many tests there will be?"

1 reply

You can create 1 test, and feed the test data based from the response from the request you make. And do it in a loop

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].