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