[{"data":1,"prerenderedAt":946},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-cypress":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":945,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-cypress\u002Findex.md",{},"Cypress",{"type":8,"value":9,"toc":936},"minimark",[10,23,44,49,149,179,183,210,214,256,263,267,296],[11,12,13,14,18,19,22],"p",{},"The Cypress plugin generates a typed ",[15,16,17],"code",{},"cy.request()"," helper for each operation in your OpenAPI spec. A helper returns ",[15,20,21],{},"Cypress.Chainable\u003C{Operation}Response>",".",[11,24,25,26,29,30,29,33,29,36,39,40,43],{},"Each helper takes grouped ",[15,27,28],{},"path",", ",[15,31,32],{},"query",[15,34,35],{},"headers",[15,37,38],{},"cookies",", and ",[15,41,42],{},"body"," parameters named after the spec.",[45,46,48],"h2",{"id":47},"installation","Installation",[50,51,53,76,96,114,132],"code-group",{"sync":52},"install",[54,55,60],"pre",{"language":56,"filename":57,"code":58,"class":59},"shell","kubb","kubb add plugin-cypress","highlights",[15,61,63],{"class":62},"language-shell",[64,65,68,72],"span",{"class":66,"style":67},"line","display: inline",[64,69,71],{"style":70},"color:#6f42c1;--hls-dark:#b392f0","kubb ",[64,73,75],{"style":74},"color:#24292e;--hls-dark:#e1e4e8","add plugin-cypress",[54,77,80],{"language":56,"filename":78,"code":79,"class":59},"bun","bun add -d @kubb\u002Fplugin-cypress",[15,81,82],{"class":62},[64,83,84,87,90,93],{"class":66,"style":67},[64,85,86],{"style":70},"bun ",[64,88,89],{"style":74},"add -d ",[64,91,92],{"style":74},"@",[64,94,95],{"style":74},"kubb\u002Fplugin-cypress",[54,97,100],{"language":56,"filename":98,"code":99,"class":59},"pnpm","pnpm add -D @kubb\u002Fplugin-cypress",[15,101,102],{"class":62},[64,103,104,107,110,112],{"class":66,"style":67},[64,105,106],{"style":70},"pnpm ",[64,108,109],{"style":74},"add -D ",[64,111,92],{"style":74},[64,113,95],{"style":74},[54,115,118],{"language":56,"filename":116,"code":117,"class":59},"npm","npm install --save-dev @kubb\u002Fplugin-cypress",[15,119,120],{"class":62},[64,121,122,125,128,130],{"class":66,"style":67},[64,123,124],{"style":70},"npm ",[64,126,127],{"style":74},"install --save-dev ",[64,129,92],{"style":74},[64,131,95],{"style":74},[54,133,136],{"language":56,"filename":134,"code":135,"class":59},"yarn","yarn add -D @kubb\u002Fplugin-cypress",[15,137,138],{"class":62},[64,139,140,143,145,147],{"class":66,"style":67},[64,141,142],{"style":70},"yarn ",[64,144,109],{"style":74},[64,146,92],{"style":74},[64,148,95],{"style":74},[11,150,151,154,155,160,161,164,165,168,169,171,172,178],{},[15,152,153],{},"kubb add"," installs the version the ",[156,157,159],"a",{"href":158},"\u002Fregistry","Kubb registry"," pins and adds ",[15,162,163],{},"pluginCypress()"," to ",[15,166,167],{},"kubb.config.ts",". It needs a ",[15,170,167],{},", so run ",[156,173,175],{"href":174},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit",[15,176,177],{},"kubb init"," first in a new project.",[45,180,182],{"id":181},"setup","Setup",[184,185,186,194,201],"ul",{},[187,188,189,190,193],"li",{},"Add ",[15,191,192],{},"@kubb\u002Fplugin-ts"," for the request and response types.",[187,195,196,197,200],{},"Install ",[15,198,199],{},"cypress"," v15 or v16 in the project that runs the tests.",[187,202,189,203,206,207,209],{},[15,204,205],{},"\"types\": [\"cypress\"]"," to the tsconfig that covers the generated files. The helpers use the global ",[15,208,6],{}," namespace.",[45,211,213],{"id":212},"options-worth-knowing","Options worth knowing",[215,216,217,233],"table",{},[218,219,220],"thead",{},[221,222,223,227,230],"tr",{},[224,225,226],"th",{},"Option",[224,228,229],{},"Default",[224,231,232],{},"What it does",[234,235,236],"tbody",{},[221,237,238,247,250],{},[239,240,241],"td",{},[156,242,244],{"href":243},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-cypress\u002Foptions#baseurl",[15,245,246],{},"baseURL",[239,248,249],{},"None",[239,251,252,253,22],{},"Prepends a host. Without it, Cypress resolves the path against its own ",[15,254,255],{},"baseUrl",[11,257,258,259,22],{},"The other options are the ",[156,260,262],{"href":261},"https:\u002F\u002Fkubb.dev\u002Fdocs\u002F5.x\u002Freference\u002Fplugin-options","shared plugin options",[45,264,266],{"id":265},"example","Example",[11,268,269,270,273,274,277,278,273,281,284,285,288,289,292,293,22],{},"This config writes the helpers to ",[15,271,272],{},"src\u002Fgen\u002Fcypress",". ",[15,275,276],{},"contentType"," keeps the JSON response of the Petstore spec, which also declares XML, so bodies are not typed as ",[15,279,280],{},"Pet | string",[15,282,283],{},"integerType: 'number'"," types the ",[15,286,287],{},"int64"," ",[15,290,291],{},"petId"," as ",[15,294,295],{},"number",[50,297,298,545,780],{},[54,299,302],{"language":300,"filename":167,"code":301,"class":59},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\nimport { adapterOas } from '@kubb\u002Fadapter-oas'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\nimport { pluginCypress } from '@kubb\u002Fplugin-cypress'\n\nexport default defineConfig({\n  input: '.\u002FpetStore.yaml',\n  output: { path: '.\u002Fsrc\u002Fgen' },\n  adapter: adapterOas({ contentType: 'application\u002Fjson', integerType: 'number' }),\n  plugins: [\n    pluginTs(),\n    pluginCypress({ output: { path: 'cypress', mode: 'directory' } }),\n  ],\n})",[15,303,305,328,329,328,345,328,361,328,377,328,379,328,393,328,410,328,433,328,470,328,482,328,495,328,532,328,541],{"class":304},"language-typescript",[64,306,307,311,315,318,321,324],{"class":66,"style":67},[64,308,310],{"style":309},"color:#d73a49;--hls-dark:#f97583","import ",[64,312,314],{"style":313},"color:#005cc5;--hls-dark:#79b8ff","{ ",[64,316,317],{"style":74},"defineConfig ",[64,319,320],{"style":313},"} ",[64,322,323],{"style":309},"from ",[64,325,327],{"style":326},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[64,330,331,333,335,338,340,342],{"class":66,"style":67},[64,332,310],{"style":309},[64,334,314],{"style":313},[64,336,337],{"style":74},"adapterOas ",[64,339,320],{"style":313},[64,341,323],{"style":309},[64,343,344],{"style":326},"'@kubb\u002Fadapter-oas'",[64,346,347,349,351,354,356,358],{"class":66,"style":67},[64,348,310],{"style":309},[64,350,314],{"style":313},[64,352,353],{"style":74},"pluginTs ",[64,355,320],{"style":313},[64,357,323],{"style":309},[64,359,360],{"style":326},"'@kubb\u002Fplugin-ts'",[64,362,363,365,367,370,372,374],{"class":66,"style":67},[64,364,310],{"style":309},[64,366,314],{"style":313},[64,368,369],{"style":74},"pluginCypress ",[64,371,320],{"style":313},[64,373,323],{"style":309},[64,375,376],{"style":326},"'@kubb\u002Fplugin-cypress'",[64,378],{"class":66,"style":67},[64,380,381,384,387,390],{"class":66,"style":67},[64,382,383],{"style":309},"export ",[64,385,386],{"style":309},"default ",[64,388,389],{"style":70},"defineConfig",[64,391,392],{"style":313},"({",[64,394,395,398,401,404,407],{"class":66,"style":67},[64,396,397],{"style":313},"  ",[64,399,400],{"style":313},"input",[64,402,403],{"style":309},": ",[64,405,406],{"style":326},"'.\u002FpetStore.yaml'",[64,408,409],{"style":309},",",[64,411,412,414,417,419,421,423,425,428,431],{"class":66,"style":67},[64,413,397],{"style":309},[64,415,416],{"style":313},"output",[64,418,403],{"style":309},[64,420,314],{"style":313},[64,422,28],{"style":313},[64,424,403],{"style":309},[64,426,427],{"style":326},"'.\u002Fsrc\u002Fgen' ",[64,429,430],{"style":313},"}",[64,432,409],{"style":309},[64,434,435,437,440,442,445,448,450,452,455,457,460,462,465,468],{"class":66,"style":67},[64,436,397],{"style":309},[64,438,439],{"style":313},"adapter",[64,441,403],{"style":309},[64,443,444],{"style":70},"adapterOas",[64,446,447],{"style":313},"({ ",[64,449,276],{"style":313},[64,451,403],{"style":309},[64,453,454],{"style":326},"'application\u002Fjson'",[64,456,29],{"style":309},[64,458,459],{"style":313},"integerType",[64,461,403],{"style":309},[64,463,464],{"style":326},"'number' ",[64,466,467],{"style":313},"})",[64,469,409],{"style":309},[64,471,472,474,477,479],{"class":66,"style":67},[64,473,397],{"style":309},[64,475,476],{"style":313},"plugins",[64,478,403],{"style":309},[64,480,481],{"style":313},"[",[64,483,484,487,490,493],{"class":66,"style":67},[64,485,486],{"style":313},"    ",[64,488,489],{"style":70},"pluginTs",[64,491,492],{"style":313},"()",[64,494,409],{"style":309},[64,496,497,499,502,504,506,508,510,512,514,517,519,522,524,527,530],{"class":66,"style":67},[64,498,486],{"style":309},[64,500,501],{"style":70},"pluginCypress",[64,503,447],{"style":313},[64,505,416],{"style":313},[64,507,403],{"style":309},[64,509,314],{"style":313},[64,511,28],{"style":313},[64,513,403],{"style":309},[64,515,516],{"style":326},"'cypress'",[64,518,29],{"style":309},[64,520,521],{"style":313},"mode",[64,523,403],{"style":309},[64,525,526],{"style":326},"'directory' ",[64,528,529],{"style":313},"} })",[64,531,409],{"style":309},[64,533,534,536,539],{"class":66,"style":67},[64,535,397],{"style":309},[64,537,538],{"style":313},"]",[64,540,409],{"style":309},[64,542,543],{"class":66,"style":67},[64,544,467],{"style":313},[54,546,549],{"language":300,"filename":547,"code":548,"class":59},"src\u002Fgen\u002Fcypress\u002FgetPetById.ts","import type { GetPetByIdOptions, GetPetByIdResponse } from '..\u002Ftypes\u002FGetPetById'\n\nexport function getPetById({ path }: GetPetByIdOptions, options: Partial\u003CCypress.RequestOptions> = {}): Cypress.Chainable\u003CGetPetByIdResponse> {\n  return cy\n    .request\u003CGetPetByIdResponse>({\n      method: 'GET',\n      url: `\u002Fpet\u002F${path.petId}`,\n      ...options,\n    })\n    .then((res) => res.body) as Cypress.Chainable\u003CGetPetByIdResponse>\n}",[15,550,551,328,575,328,577,328,644,328,654,328,672,328,687,328,715,328,726,328,732,328,776],{"class":304},[64,552,553,555,558,560,563,565,568,570,572],{"class":66,"style":67},[64,554,310],{"style":309},[64,556,557],{"style":74},"type ",[64,559,314],{"style":313},[64,561,562],{"style":70},"GetPetByIdOptions",[64,564,29],{"style":309},[64,566,567],{"style":70},"GetPetByIdResponse ",[64,569,320],{"style":313},[64,571,323],{"style":309},[64,573,574],{"style":326},"'..\u002Ftypes\u002FGetPetById'",[64,576],{"class":66,"style":67},[64,578,579,581,584,587,589,592,594,596,598,600,603,605,608,611,613,615,618,621,624,626,628,630,633,635,638,641],{"class":66,"style":67},[64,580,383],{"style":309},[64,582,583],{"style":309},"function ",[64,585,586],{"style":70},"getPetById",[64,588,447],{"style":313},[64,590,591],{"style":74},"path ",[64,593,430],{"style":313},[64,595,403],{"style":74},[64,597,562],{"style":70},[64,599,29],{"style":309},[64,601,602],{"style":74},"options",[64,604,403],{"style":74},[64,606,607],{"style":70},"Partial",[64,609,610],{"style":309},"\u003C",[64,612,6],{"style":70},[64,614,22],{"style":309},[64,616,617],{"style":313},"RequestOptions",[64,619,620],{"style":309},"> = ",[64,622,623],{"style":313},"{})",[64,625,403],{"style":74},[64,627,6],{"style":70},[64,629,22],{"style":309},[64,631,632],{"style":313},"Chainable",[64,634,610],{"style":309},[64,636,637],{"style":70},"GetPetByIdResponse",[64,639,640],{"style":309},"> ",[64,642,643],{"style":313},"{",[64,645,646,648,651],{"class":66,"style":67},[64,647,397],{"style":313},[64,649,650],{"style":309},"return ",[64,652,653],{"style":74},"cy",[64,655,656,658,660,663,665,667,670],{"class":66,"style":67},[64,657,486],{"style":74},[64,659,22],{"style":309},[64,661,662],{"style":313},"request",[64,664,610],{"style":309},[64,666,637],{"style":70},[64,668,669],{"style":309},">",[64,671,392],{"style":313},[64,673,674,677,680,682,685],{"class":66,"style":67},[64,675,676],{"style":313},"      ",[64,678,679],{"style":313},"method",[64,681,403],{"style":309},[64,683,684],{"style":326},"'GET'",[64,686,409],{"style":309},[64,688,689,691,694,696,699,702,704,706,708,710,713],{"class":66,"style":67},[64,690,676],{"style":309},[64,692,693],{"style":313},"url",[64,695,403],{"style":309},[64,697,698],{"style":326},"`\u002Fpet\u002F",[64,700,701],{"style":74},"${",[64,703,28],{"style":74},[64,705,22],{"style":309},[64,707,291],{"style":313},[64,709,430],{"style":74},[64,711,712],{"style":326},"`",[64,714,409],{"style":309},[64,716,717,719,722,724],{"class":66,"style":67},[64,718,676],{"style":309},[64,720,721],{"style":309},"...",[64,723,602],{"style":74},[64,725,409],{"style":309},[64,727,728,730],{"class":66,"style":67},[64,729,486],{"style":309},[64,731,467],{"style":313},[64,733,734,736,738,741,744,747,750,753,755,757,759,761,764,766,768,770,772,774],{"class":66,"style":67},[64,735,486],{"style":313},[64,737,22],{"style":309},[64,739,740],{"style":70},"then",[64,742,743],{"style":313},"((",[64,745,746],{"style":74},"res",[64,748,749],{"style":313},") ",[64,751,752],{"style":309},"=> ",[64,754,746],{"style":74},[64,756,22],{"style":309},[64,758,42],{"style":313},[64,760,749],{"style":313},[64,762,763],{"style":309},"as ",[64,765,6],{"style":70},[64,767,22],{"style":309},[64,769,632],{"style":313},[64,771,610],{"style":309},[64,773,637],{"style":70},[64,775,669],{"style":309},[64,777,778],{"class":66,"style":67},[64,779,430],{"style":313},[54,781,784],{"language":300,"filename":782,"code":783,"class":59},"cypress\u002Fe2e\u002Fpet.cy.ts","import { getPetById } from '..\u002F..\u002Fsrc\u002Fgen\u002Fcypress\u002FgetPetById'\n\ndescribe('Pet API', () => {\n  it('returns the pet by id', () => {\n    getPetById({ path: { petId: 1 } }).then((pet) => {\n      expect(pet.name).to.be.a('string')\n    })\n  })\n})",[15,785,786,328,802,328,804,328,824,328,844,328,882,328,922,328,927,328,932],{"class":304},[64,787,788,790,792,795,797,799],{"class":66,"style":67},[64,789,310],{"style":309},[64,791,314],{"style":313},[64,793,794],{"style":74},"getPetById ",[64,796,320],{"style":313},[64,798,323],{"style":309},[64,800,801],{"style":326},"'..\u002F..\u002Fsrc\u002Fgen\u002Fcypress\u002FgetPetById'",[64,803],{"class":66,"style":67},[64,805,806,809,812,815,817,820,822],{"class":66,"style":67},[64,807,808],{"style":70},"describe",[64,810,811],{"style":313},"(",[64,813,814],{"style":326},"'Pet API'",[64,816,29],{"style":309},[64,818,819],{"style":313},"() ",[64,821,752],{"style":309},[64,823,643],{"style":313},[64,825,826,828,831,833,836,838,840,842],{"class":66,"style":67},[64,827,397],{"style":313},[64,829,830],{"style":70},"it",[64,832,811],{"style":313},[64,834,835],{"style":326},"'returns the pet by id'",[64,837,29],{"style":309},[64,839,819],{"style":313},[64,841,752],{"style":309},[64,843,643],{"style":313},[64,845,846,848,850,852,854,856,858,860,862,865,867,869,871,873,876,878,880],{"class":66,"style":67},[64,847,486],{"style":313},[64,849,586],{"style":70},[64,851,447],{"style":313},[64,853,28],{"style":313},[64,855,403],{"style":309},[64,857,314],{"style":313},[64,859,291],{"style":313},[64,861,403],{"style":309},[64,863,864],{"style":313},"1 ",[64,866,529],{"style":313},[64,868,22],{"style":309},[64,870,740],{"style":70},[64,872,743],{"style":313},[64,874,875],{"style":74},"pet",[64,877,749],{"style":313},[64,879,752],{"style":309},[64,881,643],{"style":313},[64,883,884,886,889,891,893,895,898,901,903,906,908,911,913,915,917,920],{"class":66,"style":67},[64,885,676],{"style":313},[64,887,888],{"style":70},"expect",[64,890,811],{"style":313},[64,892,875],{"style":74},[64,894,22],{"style":309},[64,896,897],{"style":313},"name",[64,899,900],{"style":313},")",[64,902,22],{"style":309},[64,904,905],{"style":313},"to",[64,907,22],{"style":309},[64,909,910],{"style":313},"be",[64,912,22],{"style":309},[64,914,156],{"style":70},[64,916,811],{"style":313},[64,918,919],{"style":326},"'string'",[64,921,900],{"style":313},[64,923,924],{"class":66,"style":67},[64,925,926],{"style":313},"    })",[64,928,929],{"class":66,"style":67},[64,930,931],{"style":313},"  })",[64,933,934],{"class":66,"style":67},[64,935,467],{"style":313},{"title":937,"searchDepth":938,"depth":938,"links":939},"",5,[940,942,943,944],{"id":47,"depth":941,"text":48},2,{"id":181,"depth":941,"text":182},{"id":212,"depth":941,"text":213},{"id":265,"depth":941,"text":266},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-cypress",1795383544079]