[{"data":1,"prerenderedAt":379},["ShallowReactive",2],{"docs-/docs/patterns/global-hooks":3},{"id":4,"title":5,"body":6,"description":371,"extension":372,"meta":373,"navigation":374,"path":375,"seo":376,"stem":377,"__hash__":378},"docs/docs/patterns/global-hooks.md","Global Hooks",{"type":7,"value":8,"toc":364},"minimark",[9,13,17,22,63,70,153,206,210,213,242,249,258,262,308,312,328,338,342,360],[10,11,5],"h1",{"id":12},"global-hooks",[14,15,16],"p",{},"Run setup and teardown once per test run, before or after all scenarios. Use them to authenticate, seed data, or clean up — and to share values across scenarios via global variables.",[18,19,21],"h2",{"id":20},"tags","Tags",[23,24,25,38],"table",{},[26,27,28],"thead",{},[29,30,31,35],"tr",{},[32,33,34],"th",{},"Tag",[32,36,37],{},"When it runs",[39,40,41,53],"tbody",{},[29,42,43,50],{},[44,45,46],"td",{},[47,48,49],"code",{},"@BeforeAll",[44,51,52],{},"Once, before any test scenario",[29,54,55,60],{},[44,56,57],{},[47,58,59],{},"@AfterAll",[44,61,62],{},"Once, after all test scenarios (even if tests fail)",[14,64,65,66,69],{},"Place the tag on a feature file in your ",[47,67,68],{},"features/"," directory:",[71,72,77],"pre",{"className":73,"code":74,"language":75,"meta":76,"style":76},"language-gherkin shiki shiki-themes github-light github-dark","@BeforeAll\nFeature: Test Setup\n\n  Scenario: Authenticate\n    Given I prepare a request to \"my_api.login\"\n    And I set the request body to:\n      \"\"\"\n      { \"email\": \"test@example.com\", \"password\": \"testpass123\" }\n      \"\"\"\n    When I send the request\n    And I save the response path \"token\" as global variable \"auth_token\"\n    Then the response status code should be 200\n","gherkin","",[47,78,79,87,93,100,106,112,118,124,130,135,141,147],{"__ignoreMap":76},[80,81,84],"span",{"class":82,"line":83},"line",1,[80,85,86],{},"@BeforeAll\n",[80,88,90],{"class":82,"line":89},2,[80,91,92],{},"Feature: Test Setup\n",[80,94,96],{"class":82,"line":95},3,[80,97,99],{"emptyLinePlaceholder":98},true,"\n",[80,101,103],{"class":82,"line":102},4,[80,104,105],{},"  Scenario: Authenticate\n",[80,107,109],{"class":82,"line":108},5,[80,110,111],{},"    Given I prepare a request to \"my_api.login\"\n",[80,113,115],{"class":82,"line":114},6,[80,116,117],{},"    And I set the request body to:\n",[80,119,121],{"class":82,"line":120},7,[80,122,123],{},"      \"\"\"\n",[80,125,127],{"class":82,"line":126},8,[80,128,129],{},"      { \"email\": \"test@example.com\", \"password\": \"testpass123\" }\n",[80,131,133],{"class":82,"line":132},9,[80,134,123],{},[80,136,138],{"class":82,"line":137},10,[80,139,140],{},"    When I send the request\n",[80,142,144],{"class":82,"line":143},11,[80,145,146],{},"    And I save the response path \"token\" as global variable \"auth_token\"\n",[80,148,150],{"class":82,"line":149},12,[80,151,152],{},"    Then the response status code should be 200\n",[71,154,156],{"className":73,"code":155,"language":75,"meta":76,"style":76},"@AfterAll\nFeature: Test Cleanup\n\n  Scenario: Delete test user\n    Given I prepare a request to \"my_api.delete_user\"\n    And I set the following path parameters:\n      | id | {{test_user_id}} |\n    And I set the header \"Authorization\" to \"Bearer {{auth_token}}\"\n    When I send the request\n    Then the response status code should be 204\n",[47,157,158,163,168,172,177,182,187,192,197,201],{"__ignoreMap":76},[80,159,160],{"class":82,"line":83},[80,161,162],{},"@AfterAll\n",[80,164,165],{"class":82,"line":89},[80,166,167],{},"Feature: Test Cleanup\n",[80,169,170],{"class":82,"line":95},[80,171,99],{"emptyLinePlaceholder":98},[80,173,174],{"class":82,"line":102},[80,175,176],{},"  Scenario: Delete test user\n",[80,178,179],{"class":82,"line":108},[80,180,181],{},"    Given I prepare a request to \"my_api.delete_user\"\n",[80,183,184],{"class":82,"line":114},[80,185,186],{},"    And I set the following path parameters:\n",[80,188,189],{"class":82,"line":120},[80,190,191],{},"      | id | {{test_user_id}} |\n",[80,193,194],{"class":82,"line":126},[80,195,196],{},"    And I set the header \"Authorization\" to \"Bearer {{auth_token}}\"\n",[80,198,199],{"class":82,"line":132},[80,200,140],{},[80,202,203],{"class":82,"line":137},[80,204,205],{},"    Then the response status code should be 204\n",[18,207,209],{"id":208},"global-variables","Global variables",[14,211,212],{},"Store values that all scenarios can read:",[71,214,216],{"className":73,"code":215,"language":75,"meta":76,"style":76},"# From an API response\nAnd I save the response path \"token\" as global variable \"auth_token\"\n\n# Direct value\nAnd I store the value \"https://api.example.com\" into global variable \"api_base_url\"\n",[47,217,218,223,228,232,237],{"__ignoreMap":76},[80,219,220],{"class":82,"line":83},[80,221,222],{},"# From an API response\n",[80,224,225],{"class":82,"line":89},[80,226,227],{},"And I save the response path \"token\" as global variable \"auth_token\"\n",[80,229,230],{"class":82,"line":95},[80,231,99],{"emptyLinePlaceholder":98},[80,233,234],{"class":82,"line":102},[80,235,236],{},"# Direct value\n",[80,238,239],{"class":82,"line":108},[80,240,241],{},"And I store the value \"https://api.example.com\" into global variable \"api_base_url\"\n",[14,243,244,245,248],{},"Use them with the same ",[47,246,247],{},"{{variable_name}}"," syntax:",[71,250,252],{"className":73,"code":251,"language":75,"meta":76,"style":76},"And I set the header \"Authorization\" to \"Bearer {{auth_token}}\"\n",[47,253,254],{"__ignoreMap":76},[80,255,256],{"class":82,"line":83},[80,257,251],{},[18,259,261],{"id":260},"scope","Scope",[23,263,264,276],{},[26,265,266],{},[29,267,268,271,273],{},[32,269,270],{},"Variable",[32,272,261],{},[32,274,275],{},"Set with",[39,277,278,291],{},[29,279,280,283,286],{},[44,281,282],{},"Scenario",[44,284,285],{},"Current scenario",[44,287,288],{},[47,289,290],{},"I store the value ... into \"name\" variable",[29,292,293,296,299],{},[44,294,295],{},"Global",[44,297,298],{},"Entire test run",[44,300,301,304,305],{},[47,302,303],{},"... into global variable \"name\""," or ",[47,306,307],{},"I save the response path ... as global variable \"name\"",[18,309,311],{"id":310},"execution-order","Execution order",[313,314,315,321,324],"ol",{},[316,317,318,320],"li",{},[47,319,49],{}," scenarios",[316,322,323],{},"All regular test scenarios",[316,325,326,320],{},[47,327,59],{},[329,330,332],"alert",{"type":331},"warning",[14,333,334,335,337],{},"If a ",[47,336,49],{}," hook fails, no test scenarios run. Keep hooks focused and resilient.",[18,339,341],{"id":340},"next-steps","Next Steps",[343,344,345,353],"ul",{},[316,346,347,352],{},[348,349,351],"a",{"href":350},"/docs/patterns/variables","Variables"," — Scenario and environment variables",[316,354,355,359],{},[348,356,358],{"href":357},"/docs/guides/api-testing","API Testing"," — API steps for hooks",[361,362,363],"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":76,"searchDepth":89,"depth":89,"links":365},[366,367,368,369,370],{"id":20,"depth":89,"text":21},{"id":208,"depth":89,"text":209},{"id":260,"depth":89,"text":261},{"id":310,"depth":89,"text":311},{"id":340,"depth":89,"text":341},"Setup and teardown operations across your test suite","md",{},{"title":5},"/docs/patterns/global-hooks",{"title":5,"description":371},"docs/patterns/global-hooks","GxnUVUkLbPjukeLvPmSj9IbHeDkl2DrJe971WuqfSYA",1781768344734]