mirror of
https://github.com/hknsh/project-knedita.git
synced 2024-11-28 17:41:15 +00:00
23 lines
563 B
TypeScript
23 lines
563 B
TypeScript
// unfortunately k6 runtime only recognizes modules like this
|
|
import { faker } from "../../node_modules/@faker-js/faker/dist/index.cjs";
|
|
|
|
const usedUsernames = new Set();
|
|
|
|
export function generateUser() {
|
|
let username: string;
|
|
|
|
do {
|
|
const uniqueId = `${faker.number.int({ min: 5, max: 10000 })}_${Math.floor(
|
|
Math.random() * 10000,
|
|
)}`;
|
|
username = `user_${uniqueId}`;
|
|
} while (usedUsernames.has(username));
|
|
|
|
usedUsernames.add(username);
|
|
|
|
return {
|
|
username,
|
|
email: faker.internet.email().toLowerCase(),
|
|
password: "S@omeSt!0ongPa22sword",
|
|
};
|
|
}
|