Recall & Review
beginner
What is dynamic test data generation in testing?
It means creating test data on the fly during test execution instead of using fixed data. This helps tests be more flexible and realistic.
Click to reveal answer
beginner
Why use dynamic test data in Cypress tests?
Because it avoids data conflicts, makes tests independent, and simulates real user inputs better than static data.
Click to reveal answer
beginner
How can you generate a random email in Cypress?
Use JavaScript to create a string like `user${Math.floor(Math.random()*10000)}@test.com` inside your test code.
Click to reveal answer
intermediate
What Cypress command helps you reuse dynamic data across steps?
Use `cy.wrap()` to save data in a variable and `cy.then()` to access it later in the test flow.
Click to reveal answer
beginner
Give an example of dynamic test data generation for a username in Cypress.
const username = `user_${Date.now()}`;
cy.get('#username').type(username);
This uses the current time to make a unique username.Click to reveal answer
What is a main benefit of dynamic test data generation?
✗ Incorrect
Dynamic data helps avoid conflicts by creating unique inputs each time.
Which JavaScript method is commonly used to generate random numbers for test data?
✗ Incorrect
Math.random() generates a random decimal between 0 and 1, useful for random data.
In Cypress, how do you store dynamic data for reuse in later steps?
✗ Incorrect
cy.wrap() wraps data so you can chain commands and cy.then() accesses it later.
Which of these is NOT a good practice for dynamic test data?
✗ Incorrect
Hardcoding fixed values defeats the purpose of dynamic data.
What does this code do? `const email = `test${Math.floor(Math.random()*1000)}@mail.com`;`
✗ Incorrect
It creates an email with a random number to ensure uniqueness.
Explain how dynamic test data generation improves test reliability in Cypress.
Think about why fixed data can cause problems in repeated test runs.
You got /4 concepts.
Describe a simple way to generate and use a dynamic username in a Cypress test.
Focus on combining JavaScript and Cypress commands.
You got /3 concepts.