Playwright + JS · Lesson 10 of 35
Module 10: Practice Project — Test Data Management Utility
Try it yourself
Implement generateRandomUser:
${prefix}_${timestamp}, email: ${prefix}_${timestamp}@targetqa.com, role: "tester" }.The editor has a worked example. Read it, tweak it, then press Mark as complete.
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"] };
}
}Congratulations on completing the JavaScript fundamentals! In this capstone project, we will build a Test Data Management Utility. You will combine classes, random data generation, error handling, and async functions to create a reusable test data provider ready for Playwright. Let's build it!
Part of the Playwright + JS course (Playwright with JavaScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
When tests run repeatedly or in parallel, static emails like test@example.com fail on 'Account already exists' validation. Timestamps guarantee unique credentials.
Finished reading?
Review the worked example in the editor, then mark the lesson complete.