[{"data":1,"prerenderedAt":817},["ShallowReactive",2],{"page:\u002Fextensions\u002Fericlm\u002Fkubb-plugin-playwright":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":816,"source":4},"extensions\u002Fericlm\u002Fkubb-plugin-playwright\u002Findex.md",{},"Playwright",{"type":8,"value":9,"toc":806},"minimark",[10,31,54,59,127,148,152,171,357,367,371,401,694,711,715,738,746,750,803],[11,12,13,14,18,19,22,23,26,27,30],"p",{},"The Playwright plugin generates a typed request helper for each operation in your OpenAPI spec. Each helper calls ",[15,16,17],"code",{},"request.fetch"," on a Playwright ",[15,20,21],{},"APIRequestContext"," and returns the native ",[15,24,25],{},"APIResponse",", with ",[15,28,29],{},"response.json()"," typed from the spec.",[11,32,33,34,37,38,41,42,45,46,49,50,53],{},"The default resolver turns ",[15,35,36],{},"getPetById"," into ",[15,39,40],{},"pwGetPetById",", written to ",[15,43,44],{},"pwGetPetById.ts",". The ",[15,47,48],{},"pw"," prefix lets these helpers share a barrel with client helpers such as Fetch or Axios. Type names come from ",[15,51,52],{},"@kubb\u002Fplugin-ts"," unchanged.",[55,56,58],"h2",{"id":57},"installation","Installation",[60,61,63,86,100,114],"code-group",{"sync":62},"package-manager",[64,65,70],"pre",{"language":66,"filename":67,"code":68,"class":69},"shell","bun","bun add -d kubb-plugin-playwright","highlights",[15,71,73],{"class":72},"language-shell",[74,75,78,82],"span",{"class":76,"style":77},"line","display: inline",[74,79,81],{"style":80},"color:#6f42c1;--hls-dark:#b392f0","bun ",[74,83,85],{"style":84},"color:#24292e;--hls-dark:#e1e4e8","add -d kubb-plugin-playwright",[64,87,90],{"language":66,"filename":88,"code":89,"class":69},"pnpm","pnpm add -D kubb-plugin-playwright",[15,91,92],{"class":72},[74,93,94,97],{"class":76,"style":77},[74,95,96],{"style":80},"pnpm ",[74,98,99],{"style":84},"add -D kubb-plugin-playwright",[64,101,104],{"language":66,"filename":102,"code":103,"class":69},"npm","npm install --save-dev kubb-plugin-playwright",[15,105,106],{"class":72},[74,107,108,111],{"class":76,"style":77},[74,109,110],{"style":80},"npm ",[74,112,113],{"style":84},"install --save-dev kubb-plugin-playwright",[64,115,118],{"language":66,"filename":116,"code":117,"class":69},"yarn","yarn add -D kubb-plugin-playwright",[15,119,120],{"class":72},[74,121,122,125],{"class":76,"style":77},[74,123,124],{"style":80},"yarn ",[74,126,99],{"style":84},[11,128,129,130,133,134,139,140,143,144,147],{},"Or run ",[15,131,132],{},"kubb add ericlm\u002Fkubb-plugin-playwright"," to install the version the ",[135,136,138],"a",{"href":137},"\u002Fregistry","Kubb registry"," pins and add ",[15,141,142],{},"pluginPlaywright()"," to ",[15,145,146],{},"kubb.config.ts",".",[55,149,151],{"id":150},"setup","Setup",[153,154,155,162],"ul",{},[156,157,158,159,161],"li",{},"Add ",[15,160,52],{}," to the plugins array for the request and response types.",[156,163,164,165,168,169,147],{},"Install ",[15,166,167],{},"@playwright\u002Ftest"," 1.63 or newer in the project that runs the tests. Earlier versions have no generic ",[15,170,25],{},[64,172,175],{"language":173,"filename":146,"code":174,"class":69},"typescript","import { adapterOas } from '@kubb\u002Fadapter-oas'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\nimport { defineConfig } from 'kubb\u002Fconfig'\nimport { pluginPlaywright } from 'kubb-plugin-playwright'\n\nexport default defineConfig({\n  input: '.\u002FpetStore.yaml',\n  adapter: adapterOas(),\n  output: { path: '.\u002Fsrc\u002Fgen' },\n  plugins: [pluginTs(), pluginPlaywright()],\n})",[15,176,178,201,202,201,218,201,234,201,250,201,252,201,266,201,283,201,300,201,324,201,352],{"class":177},"language-typescript",[74,179,180,184,188,191,194,197],{"class":76,"style":77},[74,181,183],{"style":182},"color:#d73a49;--hls-dark:#f97583","import ",[74,185,187],{"style":186},"color:#005cc5;--hls-dark:#79b8ff","{ ",[74,189,190],{"style":84},"adapterOas ",[74,192,193],{"style":186},"} ",[74,195,196],{"style":182},"from ",[74,198,200],{"style":199},"color:#032f62;--hls-dark:#9ecbff","'@kubb\u002Fadapter-oas'","\n",[74,203,204,206,208,211,213,215],{"class":76,"style":77},[74,205,183],{"style":182},[74,207,187],{"style":186},[74,209,210],{"style":84},"pluginTs ",[74,212,193],{"style":186},[74,214,196],{"style":182},[74,216,217],{"style":199},"'@kubb\u002Fplugin-ts'",[74,219,220,222,224,227,229,231],{"class":76,"style":77},[74,221,183],{"style":182},[74,223,187],{"style":186},[74,225,226],{"style":84},"defineConfig ",[74,228,193],{"style":186},[74,230,196],{"style":182},[74,232,233],{"style":199},"'kubb\u002Fconfig'",[74,235,236,238,240,243,245,247],{"class":76,"style":77},[74,237,183],{"style":182},[74,239,187],{"style":186},[74,241,242],{"style":84},"pluginPlaywright ",[74,244,193],{"style":186},[74,246,196],{"style":182},[74,248,249],{"style":199},"'kubb-plugin-playwright'",[74,251],{"class":76,"style":77},[74,253,254,257,260,263],{"class":76,"style":77},[74,255,256],{"style":182},"export ",[74,258,259],{"style":182},"default ",[74,261,262],{"style":80},"defineConfig",[74,264,265],{"style":186},"({",[74,267,268,271,274,277,280],{"class":76,"style":77},[74,269,270],{"style":186},"  ",[74,272,273],{"style":186},"input",[74,275,276],{"style":182},": ",[74,278,279],{"style":199},"'.\u002FpetStore.yaml'",[74,281,282],{"style":182},",",[74,284,285,287,290,292,295,298],{"class":76,"style":77},[74,286,270],{"style":182},[74,288,289],{"style":186},"adapter",[74,291,276],{"style":182},[74,293,294],{"style":80},"adapterOas",[74,296,297],{"style":186},"()",[74,299,282],{"style":182},[74,301,302,304,307,309,311,314,316,319,322],{"class":76,"style":77},[74,303,270],{"style":182},[74,305,306],{"style":186},"output",[74,308,276],{"style":182},[74,310,187],{"style":186},[74,312,313],{"style":186},"path",[74,315,276],{"style":182},[74,317,318],{"style":199},"'.\u002Fsrc\u002Fgen' ",[74,320,321],{"style":186},"}",[74,323,282],{"style":182},[74,325,326,328,331,333,336,339,341,344,347,350],{"class":76,"style":77},[74,327,270],{"style":182},[74,329,330],{"style":186},"plugins",[74,332,276],{"style":182},[74,334,335],{"style":186},"[",[74,337,338],{"style":80},"pluginTs",[74,340,297],{"style":186},[74,342,343],{"style":182},", ",[74,345,346],{"style":80},"pluginPlaywright",[74,348,349],{"style":186},"()]",[74,351,282],{"style":182},[74,353,354],{"class":76,"style":77},[74,355,356],{"style":186},"})",[11,358,359,360,363,364,147],{},"The defaults write named exports to ",[15,361,362],{},"src\u002Fgen\u002Fplaywright"," and types to ",[15,365,366],{},"src\u002Fgen\u002Ftypes",[55,368,370],{"id":369},"example","Example",[11,372,373,374,377,378,381,382,384,385,343,387,343,390,393,394,397,398,147],{},"Pass the Playwright Test ",[15,375,376],{},"request"," fixture, or a context from ",[15,379,380],{},"request.newContext()",", as ",[15,383,376],{},". Each helper takes one object with only the groups the operation declares: ",[15,386,313],{},[15,388,389],{},"query",[15,391,392],{},"body",", and ",[15,395,396],{},"headers",", plus native fetch ",[15,399,400],{},"options",[64,402,405],{"language":173,"filename":403,"code":404,"class":69},"petStore.spec.ts","import { expect, test } from '@playwright\u002Ftest'\nimport { pwGetPetById } from '.\u002Fsrc\u002Fgen\u002Fplaywright'\n\ntest.use({ baseURL: 'http:\u002F\u002F127.0.0.1:3000' })\n\ntest('returns a pet', async ({ request }) => {\n  const response = await pwGetPetById({\n    request,\n    path: { petId: '123' },\n    query: { tags: ['friendly', 'small'] },\n    options: { timeout: 5_000 },\n  })\n\n  expect(response.ok()).toBeTruthy()\n  const pet = await response.json()\n  expect(pet.id).toBe('123')\n})",[15,406,407,201,428,201,444,201,446,201,469,201,471,201,500,201,520,201,529,201,551,201,581,201,603,201,609,201,611,201,637,201,659,201,690],{"class":177},[74,408,409,411,413,416,418,421,423,425],{"class":76,"style":77},[74,410,183],{"style":182},[74,412,187],{"style":186},[74,414,415],{"style":84},"expect",[74,417,343],{"style":182},[74,419,420],{"style":84},"test ",[74,422,193],{"style":186},[74,424,196],{"style":182},[74,426,427],{"style":199},"'@playwright\u002Ftest'",[74,429,430,432,434,437,439,441],{"class":76,"style":77},[74,431,183],{"style":182},[74,433,187],{"style":186},[74,435,436],{"style":84},"pwGetPetById ",[74,438,193],{"style":186},[74,440,196],{"style":182},[74,442,443],{"style":199},"'.\u002Fsrc\u002Fgen\u002Fplaywright'",[74,445],{"class":76,"style":77},[74,447,448,451,453,456,459,462,464,467],{"class":76,"style":77},[74,449,450],{"style":84},"test",[74,452,147],{"style":182},[74,454,455],{"style":80},"use",[74,457,458],{"style":186},"({ ",[74,460,461],{"style":186},"baseURL",[74,463,276],{"style":182},[74,465,466],{"style":199},"'http:\u002F\u002F127.0.0.1:3000' ",[74,468,356],{"style":186},[74,470],{"class":76,"style":77},[74,472,473,475,478,481,483,486,488,491,494,497],{"class":76,"style":77},[74,474,450],{"style":80},[74,476,477],{"style":186},"(",[74,479,480],{"style":199},"'returns a pet'",[74,482,343],{"style":182},[74,484,485],{"style":182},"async ",[74,487,458],{"style":186},[74,489,490],{"style":84},"request ",[74,492,493],{"style":186},"}) ",[74,495,496],{"style":182},"=> ",[74,498,499],{"style":186},"{",[74,501,502,504,507,510,513,516,518],{"class":76,"style":77},[74,503,270],{"style":186},[74,505,506],{"style":182},"const ",[74,508,509],{"style":84},"response ",[74,511,512],{"style":182},"= ",[74,514,515],{"style":182},"await ",[74,517,40],{"style":80},[74,519,265],{"style":186},[74,521,522,525,527],{"class":76,"style":77},[74,523,524],{"style":186},"    ",[74,526,376],{"style":84},[74,528,282],{"style":182},[74,530,531,533,535,537,539,542,544,547,549],{"class":76,"style":77},[74,532,524],{"style":182},[74,534,313],{"style":186},[74,536,276],{"style":182},[74,538,187],{"style":186},[74,540,541],{"style":186},"petId",[74,543,276],{"style":182},[74,545,546],{"style":199},"'123' ",[74,548,321],{"style":186},[74,550,282],{"style":182},[74,552,553,555,557,559,561,564,566,568,571,573,576,579],{"class":76,"style":77},[74,554,524],{"style":182},[74,556,389],{"style":186},[74,558,276],{"style":182},[74,560,187],{"style":186},[74,562,563],{"style":186},"tags",[74,565,276],{"style":182},[74,567,335],{"style":186},[74,569,570],{"style":199},"'friendly'",[74,572,343],{"style":182},[74,574,575],{"style":199},"'small'",[74,577,578],{"style":186},"] }",[74,580,282],{"style":182},[74,582,583,585,587,589,591,594,596,599,601],{"class":76,"style":77},[74,584,524],{"style":182},[74,586,400],{"style":186},[74,588,276],{"style":182},[74,590,187],{"style":186},[74,592,593],{"style":186},"timeout",[74,595,276],{"style":182},[74,597,598],{"style":186},"5_000 ",[74,600,321],{"style":186},[74,602,282],{"style":182},[74,604,605,607],{"class":76,"style":77},[74,606,270],{"style":182},[74,608,356],{"style":186},[74,610],{"class":76,"style":77},[74,612,613,615,617,619,622,624,627,630,632,635],{"class":76,"style":77},[74,614,270],{"style":186},[74,616,415],{"style":80},[74,618,477],{"style":186},[74,620,621],{"style":84},"response",[74,623,147],{"style":182},[74,625,626],{"style":80},"ok",[74,628,629],{"style":186},"())",[74,631,147],{"style":182},[74,633,634],{"style":80},"toBeTruthy",[74,636,297],{"style":186},[74,638,639,641,643,646,648,650,652,654,657],{"class":76,"style":77},[74,640,270],{"style":186},[74,642,506],{"style":182},[74,644,645],{"style":84},"pet ",[74,647,512],{"style":182},[74,649,515],{"style":182},[74,651,621],{"style":84},[74,653,147],{"style":182},[74,655,656],{"style":80},"json",[74,658,297],{"style":186},[74,660,661,663,665,667,670,672,675,678,680,683,685,688],{"class":76,"style":77},[74,662,270],{"style":186},[74,664,415],{"style":80},[74,666,477],{"style":186},[74,668,669],{"style":84},"pet",[74,671,147],{"style":182},[74,673,674],{"style":186},"id",[74,676,677],{"style":186},")",[74,679,147],{"style":182},[74,681,682],{"style":80},"toBe",[74,684,477],{"style":186},[74,686,687],{"style":199},"'123'",[74,689,677],{"style":186},[74,691,692],{"class":76,"style":77},[74,693,356],{"style":186},[11,695,696,697,699,700,703,704,707,708,147],{},"A group is required when it holds a required parameter, and ",[15,698,392],{}," is required when ",[15,701,702],{},"requestBody.required"," is ",[15,705,706],{},"true",". Path values are URI encoded, and query arrays become repeated keys such as ",[15,709,710],{},"tags=friendly&tags=small",[55,712,714],{"id":713},"options-worth-knowing","Options worth knowing",[153,716,717,729],{},[156,718,719,721,722,724,725,728],{},[15,720,461],{}," is written into every generated URL. Without it, helpers use relative paths and Playwright resolves them against the context ",[15,723,461],{},". OpenAPI ",[15,726,727],{},"servers"," are ignored.",[156,730,731,734,735,737],{},[15,732,733],{},"resolver"," renames helpers and files, for example to replace the ",[15,736,48],{}," prefix.",[11,739,740,741,745],{},"See ",[135,742,744],{"href":743},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fericlm\u002Fkubb-plugin-playwright\u002Foptions","Options"," for every option and its default.",[55,747,749],{"id":748},"limits","Limits",[153,751,752,762,776,779],{},[156,753,754,755,757,758,761],{},"The response type is the success response type from ",[15,756,52],{},". Error bodies, such as a 404 payload, are not part of the ",[15,759,760],{},"json()"," type, and the received data is not validated.",[156,763,764,765,768,769,393,772,775],{},"Request bodies support JSON (including ",[15,766,767],{},"+json"," media types), ",[15,770,771],{},"application\u002Fx-www-form-urlencoded",[15,773,774],{},"multipart\u002Fform-data",". Operations whose first body content type is something else are skipped.",[156,777,778],{},"Operations with cookie parameters are skipped.",[156,780,781,782,343,785,393,788,791,792,343,795,798,799,802],{},"OpenAPI ",[15,783,784],{},"style",[15,786,787],{},"explode",[15,789,790],{},"allowReserved"," are not applied. Pass prepared values through the native ",[15,793,794],{},"options.params",[15,796,797],{},"options.form",", or ",[15,800,801],{},"options.multipart"," for other formats.",[11,804,805],{},"The generated code makes network requests only when your tests call a helper. The plugin itself writes only inside its output path.",{"title":807,"searchDepth":808,"depth":808,"links":809},"",5,[810,812,813,814,815],{"id":57,"depth":811,"text":58},2,{"id":150,"depth":811,"text":151},{"id":369,"depth":811,"text":370},{"id":713,"depth":811,"text":714},{"id":748,"depth":811,"text":749},"\u002Fextensions\u002Fericlm\u002Fkubb-plugin-playwright",1793488212542]