[{"data":1,"prerenderedAt":915},["ShallowReactive",2],{"docs-/docs/features/random-data-generation":3},{"id":4,"title":5,"body":6,"description":906,"extension":907,"meta":908,"navigation":909,"path":911,"seo":912,"stem":913,"__hash__":914},"docs/docs/3.features/6.random-data-generation.md","Random Data Generation",{"type":7,"value":8,"toc":885},"minimark",[9,13,17,22,33,40,44,49,52,84,88,91,123,127,130,200,264,269,328,332,335,371,380,384,387,439,482,486,489,513,522,526,529,558,568,572,576,579,656,660,663,703,707,742,746,758,804,808,815,821,825,853,857,881],[10,11,5],"h1",{"id":12},"random-data-generation",[14,15,16],"p",{},"TestFlowKit's random data engine lets you inject dynamic, random values directly in your Gherkin files — without writing any step code. Values are generated at runtime, each time the step executes.",[18,19,21],"h2",{"id":20},"syntax","Syntax",[23,24,29],"pre",{"className":25,"code":27,"language":28},[26],"language-text","{{ rand:type }}\n{{ rand:type:key=value }}\n{{ rand:type:key=value,key=value }}\n","text",[30,31,27],"code",{"__ignoreMap":32},"",[14,34,35,36,39],{},"The ",[30,37,38],{},"rand:"," prefix tells the engine to generate a value. Everything after is the type and its options.",[18,41,43],{"id":42},"supported-generators","Supported Generators",[45,46,48],"h3",{"id":47},"uuid","UUID",[14,50,51],{},"Generates a random UUID v4.",[23,53,57],{"className":54,"code":55,"language":56,"meta":32,"style":32},"language-gherkin shiki shiki-themes github-light github-dark","When I set the request body to:\n  \"\"\"\n  { \"id\": \"{{ rand:uuid }}\" }\n  \"\"\"\n","gherkin",[30,58,59,67,73,79],{"__ignoreMap":32},[60,61,64],"span",{"class":62,"line":63},"line",1,[60,65,66],{},"When I set the request body to:\n",[60,68,70],{"class":62,"line":69},2,[60,71,72],{},"  \"\"\"\n",[60,74,76],{"class":62,"line":75},3,[60,77,78],{},"  { \"id\": \"{{ rand:uuid }}\" }\n",[60,80,82],{"class":62,"line":81},4,[60,83,72],{},[45,85,87],{"id":86},"email","Email",[14,89,90],{},"Generates a random email address. Optionally pin the domain.",[23,92,94],{"className":54,"code":93,"language":56,"meta":32,"style":32},"# Random email with random domain\nAnd I store the value \"{{ rand:email }}\" into \"user_email\" variable\n\n# Force a specific domain\nAnd I store the value \"{{ rand:email:domain=kil.com }}\" into \"user_email\" variable\n",[30,95,96,101,106,112,117],{"__ignoreMap":32},[60,97,98],{"class":62,"line":63},[60,99,100],{},"# Random email with random domain\n",[60,102,103],{"class":62,"line":69},[60,104,105],{},"And I store the value \"{{ rand:email }}\" into \"user_email\" variable\n",[60,107,108],{"class":62,"line":75},[60,109,111],{"emptyLinePlaceholder":110},true,"\n",[60,113,114],{"class":62,"line":81},[60,115,116],{},"# Force a specific domain\n",[60,118,120],{"class":62,"line":119},5,[60,121,122],{},"And I store the value \"{{ rand:email:domain=kil.com }}\" into \"user_email\" variable\n",[45,124,126],{"id":125},"phone-number","Phone Number",[14,128,129],{},"Generates a valid phone number for a given country.",[131,132,133,149],"table",{},[134,135,136],"thead",{},[137,138,139,143,146],"tr",{},[140,141,142],"th",{},"Option",[140,144,145],{},"Values",[140,147,148],{},"Default",[150,151,152,178],"tbody",{},[137,153,154,160,174],{},[155,156,157],"td",{},[30,158,159],{},"country",[155,161,162,163,166,167,166,170,173],{},"ISO 3166-1 alpha-2 code (",[30,164,165],{},"FR",", ",[30,168,169],{},"US",[30,171,172],{},"GB",", …)",[155,175,176],{},[30,177,169],{},[137,179,180,185,196],{},[155,181,182],{},[30,183,184],{},"format",[155,186,187,166,190,166,193],{},[30,188,189],{},"e164",[30,191,192],{},"national",[30,194,195],{},"international",[155,197,198],{},[30,199,189],{},[23,201,203],{"className":54,"code":202,"language":56,"meta":32,"style":32},"# France — E.164 (best for APIs)\nAnd I store the value \"{{ rand:phone:country=FR,format=e164 }}\" into \"phone\" variable\n# → +33612345678\n\n# USA — national format (for frontend forms)\nAnd I store the value \"{{ rand:phone:country=US,format=national }}\" into \"phone\" variable\n# → (415) 555-2671\n\n# USA — international\nAnd I store the value \"{{ rand:phone:country=US,format=international }}\" into \"phone\" variable\n# → +1 415-555-2671\n",[30,204,205,210,215,220,224,229,235,241,246,252,258],{"__ignoreMap":32},[60,206,207],{"class":62,"line":63},[60,208,209],{},"# France — E.164 (best for APIs)\n",[60,211,212],{"class":62,"line":69},[60,213,214],{},"And I store the value \"{{ rand:phone:country=FR,format=e164 }}\" into \"phone\" variable\n",[60,216,217],{"class":62,"line":75},[60,218,219],{},"# → +33612345678\n",[60,221,222],{"class":62,"line":81},[60,223,111],{"emptyLinePlaceholder":110},[60,225,226],{"class":62,"line":119},[60,227,228],{},"# USA — national format (for frontend forms)\n",[60,230,232],{"class":62,"line":231},6,[60,233,234],{},"And I store the value \"{{ rand:phone:country=US,format=national }}\" into \"phone\" variable\n",[60,236,238],{"class":62,"line":237},7,[60,239,240],{},"# → (415) 555-2671\n",[60,242,244],{"class":62,"line":243},8,[60,245,111],{"emptyLinePlaceholder":110},[60,247,249],{"class":62,"line":248},9,[60,250,251],{},"# USA — international\n",[60,253,255],{"class":62,"line":254},10,[60,256,257],{},"And I store the value \"{{ rand:phone:country=US,format=international }}\" into \"phone\" variable\n",[60,259,261],{"class":62,"line":260},11,[60,262,263],{},"# → +1 415-555-2671\n",[265,266,268],"h4",{"id":267},"phone-format-guide","Phone format guide",[131,270,271,284],{},[134,272,273],{},[137,274,275,278,281],{},[140,276,277],{},"Format",[140,279,280],{},"Example",[140,282,283],{},"Use for",[150,285,286,300,314],{},[137,287,288,292,297],{},[155,289,290],{},[30,291,189],{},[155,293,294],{},[30,295,296],{},"+33612345678",[155,298,299],{},"APIs, databases, assertions",[137,301,302,306,311],{},[155,303,304],{},[30,305,192],{},[155,307,308],{},[30,309,310],{},"06 12 34 56 78",[155,312,313],{},"Frontend form fields",[137,315,316,320,325],{},[155,317,318],{},[30,319,195],{},[155,321,322],{},[30,323,324],{},"+33 6 12 34 56 78",[155,326,327],{},"UI display, logs",[45,329,331],{"id":330},"integer","Integer",[14,333,334],{},"Generates a random integer within a range.",[131,336,337,345],{},[134,338,339],{},[137,340,341,343],{},[140,342,142],{},[140,344,148],{},[150,346,347,359],{},[137,348,349,354],{},[155,350,351],{},[30,352,353],{},"min",[155,355,356],{},[30,357,358],{},"0",[137,360,361,366],{},[155,362,363],{},[30,364,365],{},"max",[155,367,368],{},[30,369,370],{},"1000",[23,372,374],{"className":54,"code":373,"language":56,"meta":32,"style":32},"And I store the value \"{{ rand:int:min=1,max=99 }}\" into \"quantity\" variable\n",[30,375,376],{"__ignoreMap":32},[60,377,378],{"class":62,"line":63},[60,379,373],{},[45,381,383],{"id":382},"date","Date",[14,385,386],{},"Generates a random date.",[131,388,389,399],{},[134,390,391],{},[137,392,393,395,397],{},[140,394,142],{},[140,396,145],{},[140,398,148],{},[150,400,401,423],{},[137,402,403,408,419],{},[155,404,405],{},[30,406,407],{},"direction",[155,409,410,166,413,166,416],{},[30,411,412],{},"past",[30,414,415],{},"future",[30,417,418],{},"now",[155,420,421],{},[30,422,412],{},[137,424,425,429,432],{},[155,426,427],{},[30,428,184],{},[155,430,431],{},"Any Go time layout",[155,433,434,435,438],{},"RFC3339 (",[30,436,437],{},"2006-01-02T15:04:05Z07:00",")",[23,440,442],{"className":54,"code":441,"language":56,"meta":32,"style":32},"# Past date in ISO 8601\nAnd I store the value \"{{ rand:date:direction=past }}\" into \"birth_date\" variable\n\n# Future date in short format\nAnd I store the value \"{{ rand:date:direction=future,format=2006-01-02 }}\" into \"expiry\" variable\n\n# Current timestamp\nAnd I store the value \"{{ rand:date:direction=now }}\" into \"timestamp\" variable\n",[30,443,444,449,454,458,463,468,472,477],{"__ignoreMap":32},[60,445,446],{"class":62,"line":63},[60,447,448],{},"# Past date in ISO 8601\n",[60,450,451],{"class":62,"line":69},[60,452,453],{},"And I store the value \"{{ rand:date:direction=past }}\" into \"birth_date\" variable\n",[60,455,456],{"class":62,"line":75},[60,457,111],{"emptyLinePlaceholder":110},[60,459,460],{"class":62,"line":81},[60,461,462],{},"# Future date in short format\n",[60,464,465],{"class":62,"line":119},[60,466,467],{},"And I store the value \"{{ rand:date:direction=future,format=2006-01-02 }}\" into \"expiry\" variable\n",[60,469,470],{"class":62,"line":231},[60,471,111],{"emptyLinePlaceholder":110},[60,473,474],{"class":62,"line":237},[60,475,476],{},"# Current timestamp\n",[60,478,479],{"class":62,"line":243},[60,480,481],{},"And I store the value \"{{ rand:date:direction=now }}\" into \"timestamp\" variable\n",[45,483,485],{"id":484},"words-free-text","Words / Free Text",[14,487,488],{},"Generates a random sentence with the given number of words.",[131,490,491,499],{},[134,492,493],{},[137,494,495,497],{},[140,496,142],{},[140,498,148],{},[150,500,501],{},[137,502,503,508],{},[155,504,505],{},[30,506,507],{},"count",[155,509,510],{},[30,511,512],{},"3",[23,514,516],{"className":54,"code":515,"language":56,"meta":32,"style":32},"And I store the value \"{{ rand:words:count=6 }}\" into \"description\" variable\n",[30,517,518],{"__ignoreMap":32},[60,519,520],{"class":62,"line":63},[60,521,515],{},[45,523,525],{"id":524},"regex","Regex",[14,527,528],{},"Generates a string matching a regular expression.",[23,530,532],{"className":54,"code":531,"language":56,"meta":32,"style":32},"# Generates e.g. \"ABC-1234\"\nAnd I store the value \"{{ rand:regex:pattern=[A-Z]{3}-\\d{4} }}\" into \"code\" variable\n\n# Generates a hex color\nAnd I store the value \"{{ rand:regex:pattern=#[0-9A-F]{6} }}\" into \"color\" variable\n",[30,533,534,539,544,548,553],{"__ignoreMap":32},[60,535,536],{"class":62,"line":63},[60,537,538],{},"# Generates e.g. \"ABC-1234\"\n",[60,540,541],{"class":62,"line":69},[60,542,543],{},"And I store the value \"{{ rand:regex:pattern=[A-Z]{3}-\\d{4} }}\" into \"code\" variable\n",[60,545,546],{"class":62,"line":75},[60,547,111],{"emptyLinePlaceholder":110},[60,549,550],{"class":62,"line":81},[60,551,552],{},"# Generates a hex color\n",[60,554,555],{"class":62,"line":119},[60,556,557],{},"And I store the value \"{{ rand:regex:pattern=#[0-9A-F]{6} }}\" into \"color\" variable\n",[559,560,562],"alert",{"type":561},"info",[14,563,35,564,567],{},[30,565,566],{},"pattern="," option consumes the rest of the expression, so commas and colons inside the regex are safe.",[18,569,571],{"id":570},"usage-patterns","Usage Patterns",[45,573,575],{"id":574},"rest-api","REST API",[14,577,578],{},"Generate a dynamic request body each test run:",[23,580,582],{"className":54,"code":581,"language":56,"meta":32,"style":32},"Scenario: Create a user with random data\n  Given I prepare a request to \"myapi.create_user\"\n  And I store the value \"{{ rand:uuid }}\" into \"user_id\" variable\n  And I store the value \"{{ rand:email:domain=kil.com }}\" into \"user_email\" variable\n  When I set the request body to:\n    \"\"\"\n    {\n      \"id\": \"{{user_id}}\",\n      \"email\": \"{{user_email}}\"\n    }\n    \"\"\"\n  And I send the request\n  Then the response status code should be 201\n  And the response should contain \"{{user_email}}\"\n",[30,583,584,589,594,599,604,609,614,619,624,629,634,638,644,650],{"__ignoreMap":32},[60,585,586],{"class":62,"line":63},[60,587,588],{},"Scenario: Create a user with random data\n",[60,590,591],{"class":62,"line":69},[60,592,593],{},"  Given I prepare a request to \"myapi.create_user\"\n",[60,595,596],{"class":62,"line":75},[60,597,598],{},"  And I store the value \"{{ rand:uuid }}\" into \"user_id\" variable\n",[60,600,601],{"class":62,"line":81},[60,602,603],{},"  And I store the value \"{{ rand:email:domain=kil.com }}\" into \"user_email\" variable\n",[60,605,606],{"class":62,"line":119},[60,607,608],{},"  When I set the request body to:\n",[60,610,611],{"class":62,"line":231},[60,612,613],{},"    \"\"\"\n",[60,615,616],{"class":62,"line":237},[60,617,618],{},"    {\n",[60,620,621],{"class":62,"line":243},[60,622,623],{},"      \"id\": \"{{user_id}}\",\n",[60,625,626],{"class":62,"line":248},[60,627,628],{},"      \"email\": \"{{user_email}}\"\n",[60,630,631],{"class":62,"line":254},[60,632,633],{},"    }\n",[60,635,636],{"class":62,"line":260},[60,637,613],{},[60,639,641],{"class":62,"line":640},12,[60,642,643],{},"  And I send the request\n",[60,645,647],{"class":62,"line":646},13,[60,648,649],{},"  Then the response status code should be 201\n",[60,651,653],{"class":62,"line":652},14,[60,654,655],{},"  And the response should contain \"{{user_email}}\"\n",[45,657,659],{"id":658},"graphql","GraphQL",[14,661,662],{},"Random values work directly in GraphQL variable tables:",[23,664,666],{"className":54,"code":665,"language":56,"meta":32,"style":32},"Scenario: Create a post with random content\n  Given I prepare a request to \"myapi.create_post\"\n  And I set the following GraphQL variables:\n    | title | {{ rand:words:count=4 }} |\n    | body  | {{ rand:words:count=12 }} |\n  When I send the request\n  Then the GraphQL response should not have errors\n",[30,667,668,673,678,683,688,693,698],{"__ignoreMap":32},[60,669,670],{"class":62,"line":63},[60,671,672],{},"Scenario: Create a post with random content\n",[60,674,675],{"class":62,"line":69},[60,676,677],{},"  Given I prepare a request to \"myapi.create_post\"\n",[60,679,680],{"class":62,"line":75},[60,681,682],{},"  And I set the following GraphQL variables:\n",[60,684,685],{"class":62,"line":81},[60,686,687],{},"    | title | {{ rand:words:count=4 }} |\n",[60,689,690],{"class":62,"line":119},[60,691,692],{},"    | body  | {{ rand:words:count=12 }} |\n",[60,694,695],{"class":62,"line":231},[60,696,697],{},"  When I send the request\n",[60,699,700],{"class":62,"line":237},[60,701,702],{},"  Then the GraphQL response should not have errors\n",[45,704,706],{"id":705},"frontend-forms","Frontend Forms",[23,708,710],{"className":54,"code":709,"language":56,"meta":32,"style":32},"Scenario: Register with random phone number\n  Given the user goes to the \"registration\" page\n  And I store the value \"{{ rand:phone:country=FR,format=national }}\" into \"phone\" variable\n  When the user enters \"{{phone}}\" into the \"phone\" field\n  And the user clicks the \"submit\" button\n  Then the \"confirmation\" should be visible\n",[30,711,712,717,722,727,732,737],{"__ignoreMap":32},[60,713,714],{"class":62,"line":63},[60,715,716],{},"Scenario: Register with random phone number\n",[60,718,719],{"class":62,"line":69},[60,720,721],{},"  Given the user goes to the \"registration\" page\n",[60,723,724],{"class":62,"line":75},[60,725,726],{},"  And I store the value \"{{ rand:phone:country=FR,format=national }}\" into \"phone\" variable\n",[60,728,729],{"class":62,"line":81},[60,730,731],{},"  When the user enters \"{{phone}}\" into the \"phone\" field\n",[60,733,734],{"class":62,"line":119},[60,735,736],{},"  And the user clicks the \"submit\" button\n",[60,738,739],{"class":62,"line":231},[60,740,741],{},"  Then the \"confirmation\" should be visible\n",[18,743,745],{"id":744},"reusing-a-generated-value","Reusing a Generated Value",[14,747,748,749,752,753,757],{},"Each ",[30,750,751],{},"{{ rand:uuid }}"," call generates a ",[754,755,756],"strong",{},"new"," value. To use the same value multiple times, store it first:",[23,759,761],{"className":54,"code":760,"language":56,"meta":32,"style":32},"# Store once\nAnd I store the value \"{{ rand:uuid }}\" into \"request_id\" variable\n\n# Reuse as many times as needed\nWhen I set the request body to:\n  \"\"\"\n  { \"id\": \"{{request_id}}\" }\n  \"\"\"\nThen the response should contain \"{{request_id}}\"\n",[30,762,763,768,773,777,782,786,790,795,799],{"__ignoreMap":32},[60,764,765],{"class":62,"line":63},[60,766,767],{},"# Store once\n",[60,769,770],{"class":62,"line":69},[60,771,772],{},"And I store the value \"{{ rand:uuid }}\" into \"request_id\" variable\n",[60,774,775],{"class":62,"line":75},[60,776,111],{"emptyLinePlaceholder":110},[60,778,779],{"class":62,"line":81},[60,780,781],{},"# Reuse as many times as needed\n",[60,783,784],{"class":62,"line":119},[60,785,66],{},[60,787,788],{"class":62,"line":231},[60,789,72],{},[60,791,792],{"class":62,"line":237},[60,793,794],{},"  { \"id\": \"{{request_id}}\" }\n",[60,796,797],{"class":62,"line":243},[60,798,72],{},[60,800,801],{"class":62,"line":248},[60,802,803],{},"Then the response should contain \"{{request_id}}\"\n",[18,805,807],{"id":806},"reproducibility","Reproducibility",[14,809,810,811,814],{},"Every generated value is logged to the console output at execution time with the ",[30,812,813],{},"[rand]"," prefix, so failing tests can be investigated:",[23,816,819],{"className":817,"code":818,"language":28},[26],"[rand] generated '{{ rand:uuid }}' → 4a8b2c1d-...\n[rand] generated '{{ rand:phone:country=FR,format=e164 }}' → +33612345678\n",[30,820,818],{"__ignoreMap":32},[18,822,824],{"id":823},"best-practices","Best Practices",[826,827,828,835,840,843,846],"ul",{},[829,830,831,832,834],"li",{},"✅ Use ",[30,833,751],{}," for IDs — guaranteed unique, no collision",[829,836,831,837,839],{},[30,838,189],{}," format for phone numbers in API tests — most stable",[829,841,842],{},"✅ Store generated values into variables before reusing them",[829,844,845],{},"✅ Check the console log when a test fails — the exact values are printed",[829,847,848,849,852],{},"⚠️ Avoid ",[30,850,851],{},"{{ rand:... }}"," in config.yml — it is only resolved at step execution time, not at config load time",[18,854,856],{"id":855},"next-steps","Next Steps",[826,858,859,867,874],{},[829,860,861,866],{},[862,863,865],"a",{"href":864},"/docs/features/variables","Variables"," — Store and reuse variables across steps",[829,868,869,873],{},[862,870,872],{"href":871},"/docs/features/api-testing","API Testing"," — REST and GraphQL testing",[829,875,876,880],{},[862,877,879],{"href":878},"/docs/features/frontend-testing","Frontend Testing"," — Browser automation steps",[882,883,884],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":32,"searchDepth":69,"depth":69,"links":886},[887,888,897,902,903,904,905],{"id":20,"depth":69,"text":21},{"id":42,"depth":69,"text":43,"children":889},[890,891,892,893,894,895,896],{"id":47,"depth":75,"text":48},{"id":86,"depth":75,"text":87},{"id":125,"depth":75,"text":126},{"id":330,"depth":75,"text":331},{"id":382,"depth":75,"text":383},{"id":484,"depth":75,"text":485},{"id":524,"depth":75,"text":525},{"id":570,"depth":69,"text":571,"children":898},[899,900,901],{"id":574,"depth":75,"text":575},{"id":658,"depth":75,"text":659},{"id":705,"depth":75,"text":706},{"id":744,"depth":69,"text":745},{"id":806,"depth":69,"text":807},{"id":823,"depth":69,"text":824},{"id":855,"depth":69,"text":856},"Generate dynamic, random test data inline in your Gherkin files using the {{ rand:type:options }} syntax","md",{},{"title":910},"Random Data","/docs/features/random-data-generation",{"title":5,"description":906},"docs/3.features/6.random-data-generation","QF6ohqVe_4Wiu6UvNCm5e_vwmWGgrHkHP_MTcDF-j0Q",1780146309043]