10. Capstone Project: Test Data Management Utility

Capstone: Test Data Management Utility

In real-world automation, hardcoding static emails leads to collision errors in parallel test runs. We build a utility that dynamically generates isolated test data payloads:
export class TestDataManager {
  static generateRandomUser(prefix = "user") {
    const timestamp = Date.now();
    return {
      username: ${prefix}_${timestamp},
      email: ${prefix}_${timestamp}@targetqa.com,
      role: "tester",
      createdAt: new Date().toISOString()
    };
  }

static async loadUserByRole(role) {
if (!role) throw new Error("Role parameter is required");
return { role, permissions: ["read", "write"] };
}
}

Task

  • Implement generateRandomUser:
  • 1. Accept prefix string defaulting to "user".
  • 2. Generate timestamp with Date.now().
  • 3. Return { username: `${prefix}_${timestamp}`, email: `${prefix}_${timestamp}@targetqa.com`, role: "tester" }.
πŸ’‘Common doubts
Did you like the problem?
Lesson 10 of 35
JavaScript
Loading code editor…
Next