[{"data":1,"prerenderedAt":384},["ShallowReactive",2],{"docs-/docs/patterns/macros":3},{"id":4,"title":5,"body":6,"description":376,"extension":377,"meta":378,"navigation":379,"path":380,"seo":381,"stem":382,"__hash__":383},"docs/docs/patterns/macros.md","Macros",{"type":7,"value":8,"toc":368},"minimark",[9,13,22,27,38,91,95,102,137,143,147,258,262,286,290,343,347,364],[10,11,5],"h1",{"id":12},"macros",[14,15,16,17,21],"p",{},"Macros are reusable scenarios you define once and call with different parameters. Use ",[18,19,20],"code",{},"${variable}"," placeholders in the macro, then pass values via a data table at call time.",[23,24,26],"h2",{"id":25},"define-a-macro","Define a macro",[14,28,29,30,33,34,37],{},"Tag the scenario with ",[18,31,32],{},"@macro"," and use ",[18,35,36],{},"${variable_name}"," for placeholders:",[39,40,45],"pre",{"className":41,"code":42,"language":43,"meta":44,"style":44},"language-gherkin shiki shiki-themes github-light github-dark","@macro\nScenario: Login as user\n  Given the user goes to the \"login\" page\n  When the user enters \"${email}\" into the \"email\" field\n  And the user enters \"${password}\" into the \"password\" field\n  And the user clicks the \"login\" button\n  Then the \"dashboard\" should be visible\n","gherkin","",[18,46,47,55,61,67,73,79,85],{"__ignoreMap":44},[48,49,52],"span",{"class":50,"line":51},"line",1,[48,53,54],{},"@macro\n",[48,56,58],{"class":50,"line":57},2,[48,59,60],{},"Scenario: Login as user\n",[48,62,64],{"class":50,"line":63},3,[48,65,66],{},"  Given the user goes to the \"login\" page\n",[48,68,70],{"class":50,"line":69},4,[48,71,72],{},"  When the user enters \"${email}\" into the \"email\" field\n",[48,74,76],{"class":50,"line":75},5,[48,77,78],{},"  And the user enters \"${password}\" into the \"password\" field\n",[48,80,82],{"class":50,"line":81},6,[48,83,84],{},"  And the user clicks the \"login\" button\n",[48,86,88],{"class":50,"line":87},7,[48,89,90],{},"  Then the \"dashboard\" should be visible\n",[23,92,94],{"id":93},"call-a-macro","Call a macro",[14,96,97,98,101],{},"Use the scenario name as a step, followed by a two-column table (",[18,99,100],{},"variable | value","):",[39,103,105],{"className":41,"code":104,"language":43,"meta":44,"style":44},"Scenario: Admin can access dashboard\n  Given Login as user\n    | email    | admin@example.com |\n    | password | admin123          |\n  When the user clicks the \"admin_panel\" link\n  Then the \"admin_dashboard\" should be visible\n",[18,106,107,112,117,122,127,132],{"__ignoreMap":44},[48,108,109],{"class":50,"line":51},[48,110,111],{},"Scenario: Admin can access dashboard\n",[48,113,114],{"class":50,"line":57},[48,115,116],{},"  Given Login as user\n",[48,118,119],{"class":50,"line":63},[48,120,121],{},"    | email    | admin@example.com |\n",[48,123,124],{"class":50,"line":69},[48,125,126],{},"    | password | admin123          |\n",[48,128,129],{"class":50,"line":75},[48,130,131],{},"  When the user clicks the \"admin_panel\" link\n",[48,133,134],{"class":50,"line":81},[48,135,136],{},"  Then the \"admin_dashboard\" should be visible\n",[14,138,139,140,142],{},"Each row maps one ",[18,141,20],{}," to a value. Missing variables cause the macro to fail.",[23,144,146],{"id":145},"api-example","API example",[39,148,150],{"className":41,"code":149,"language":43,"meta":44,"style":44},"@macro\nScenario: I try to create a new post with the following details:\n  Given I prepare a request to \"jsonplaceholder.create_post\"\n  When I set the request body to:\n    \"\"\"\n    {\n      \"title\": \"${title}\",\n      \"body\": \"${body}\",\n      \"userId\": ${userId}\n    }\n    \"\"\"\n  And I send the request\n\nScenario: Create a new post\n  When I try to create a new post with the following details:\n    | title  | Test Post Title |\n    | body   | Test body       |\n    | userId | 1               |\n  Then the response status code should be 201\n",[18,151,152,156,161,166,171,176,181,186,192,198,204,209,215,222,228,234,240,246,252],{"__ignoreMap":44},[48,153,154],{"class":50,"line":51},[48,155,54],{},[48,157,158],{"class":50,"line":57},[48,159,160],{},"Scenario: I try to create a new post with the following details:\n",[48,162,163],{"class":50,"line":63},[48,164,165],{},"  Given I prepare a request to \"jsonplaceholder.create_post\"\n",[48,167,168],{"class":50,"line":69},[48,169,170],{},"  When I set the request body to:\n",[48,172,173],{"class":50,"line":75},[48,174,175],{},"    \"\"\"\n",[48,177,178],{"class":50,"line":81},[48,179,180],{},"    {\n",[48,182,183],{"class":50,"line":87},[48,184,185],{},"      \"title\": \"${title}\",\n",[48,187,189],{"class":50,"line":188},8,[48,190,191],{},"      \"body\": \"${body}\",\n",[48,193,195],{"class":50,"line":194},9,[48,196,197],{},"      \"userId\": ${userId}\n",[48,199,201],{"class":50,"line":200},10,[48,202,203],{},"    }\n",[48,205,207],{"class":50,"line":206},11,[48,208,175],{},[48,210,212],{"class":50,"line":211},12,[48,213,214],{},"  And I send the request\n",[48,216,218],{"class":50,"line":217},13,[48,219,221],{"emptyLinePlaceholder":220},true,"\n",[48,223,225],{"class":50,"line":224},14,[48,226,227],{},"Scenario: Create a new post\n",[48,229,231],{"class":50,"line":230},15,[48,232,233],{},"  When I try to create a new post with the following details:\n",[48,235,237],{"class":50,"line":236},16,[48,238,239],{},"    | title  | Test Post Title |\n",[48,241,243],{"class":50,"line":242},17,[48,244,245],{},"    | body   | Test body       |\n",[48,247,249],{"class":50,"line":248},18,[48,250,251],{},"    | userId | 1               |\n",[48,253,255],{"class":50,"line":254},19,[48,256,257],{},"  Then the response status code should be 201\n",[23,259,261],{"id":260},"tips","Tips",[263,264,265,269,276,279],"ul",{},[266,267,268],"li",{},"Keep macros focused — one clear action per macro",[266,270,271,272,275],{},"Put macro definitions in a dedicated ",[18,273,274],{},"features/macros/"," folder",[266,277,278],{},"Macro scenarios are excluded from normal test runs (only invoked explicitly)",[266,280,281,282,285],{},"Variable names in the table must match ",[18,283,284],{},"${placeholders}"," exactly",[23,287,289],{"id":288},"troubleshooting","Troubleshooting",[291,292,293,306],"table",{},[294,295,296],"thead",{},[297,298,299,303],"tr",{},[300,301,302],"th",{},"Problem",[300,304,305],{},"Fix",[307,308,309,321,332],"tbody",{},[297,310,311,315],{},[312,313,314],"td",{},"Macro not found",[312,316,317,318,320],{},"Check ",[18,319,32],{}," tag and exact scenario name",[297,322,323,329],{},[312,324,325,328],{},[18,326,327],{},"${var}"," appears literally",[312,330,331],{},"Variable name in the table doesn't match the placeholder",[297,333,334,337],{},[312,335,336],{},"Wrong values",[312,338,339,340],{},"Each table row must have exactly 2 columns: ",[18,341,342],{},"name | value",[23,344,346],{"id":345},"next-steps","Next Steps",[263,348,349,357],{},[266,350,351,356],{},[352,353,355],"a",{"href":354},"/docs/patterns/global-hooks","Global Hooks"," — Setup and teardown across the suite",[266,358,359,363],{},[352,360,362],{"href":361},"/docs/patterns/variables","Variables"," — Scenario and environment variables",[365,366,367],"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":44,"searchDepth":57,"depth":57,"links":369},[370,371,372,373,374,375],{"id":25,"depth":57,"text":26},{"id":93,"depth":57,"text":94},{"id":145,"depth":57,"text":146},{"id":260,"depth":57,"text":261},{"id":288,"depth":57,"text":289},{"id":345,"depth":57,"text":346},"Create reusable, parameterized test patterns with macros","md",{},{"title":5},"/docs/patterns/macros",{"title":5,"description":376},"docs/patterns/macros","CLMvmBDMhnC6cw0g5p5-9UJVoE3pcaQF5OCMdlqxgUM",1781768344730]