Understandably, guid / uuid is usually not hard-coded so i wanted to have an assertion to check if the value generated is a valid guid format. Closest I got was: https://stackoverflow.com/questions/7905929/how-to-test-valid-uuid-guid
This thread is trying to answer question "Is there a way to assert if a value is a guid/uuid?"
function validateUUID(uuid) { const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/; return uuidRegex.test(uuid); } function validateGUID(guid) { const guidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/; return guidRegex.test(guid); }
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].