[{"data":1,"prerenderedAt":498},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-cypress":3},{"id":4,"title":5,"body":6,"description":479,"extension":487,"frontmatter":488,"heading":5,"meta":489,"navigation":490,"order":491,"path":492,"seo":493,"sitemap":494,"source":4,"stem":495,"__hash__":496,"hasPopups":497},"extensions\u002Fextensions\u002Fkubb-labs\u002Fplugin-cypress\u002Findex.md","Cypress",{"type":7,"value":8,"toc":478},"minimark",[9,18,40,45,129,149,153,180,184,195,203,207,213,342,356],[10,11,12,13,17],"p",{},"The Cypress plugin generates a typed ",[14,15,16],"code",{},"cy.request()"," helper for each operation in your OpenAPI spec.",[10,19,20,21,24,25,24,28,31,32,35,36,39],{},"Each helper takes grouped ",[14,22,23],{},"path",", ",[14,26,27],{},"query",[14,29,30],{},"headers",", and ",[14,33,34],{},"body"," parameters named after the spec. It returns the response body typed as ",[14,37,38],{},"Cypress.Chainable\u003C{Operation}Response>",".",[41,42,44],"h2",{"id":43},"installation","Installation",[46,47,49,78,95,113],"code-group",{"sync":48},"package-manager",[50,51,56],"pre",{"language":52,"filename":53,"code":54,"class":55},"shell","bun","bun add -d @kubb\u002Fplugin-cypress","shiki shiki-themes github-light github-dark dark:github-dark",[14,57,59],{"class":58},"language-shell",[60,61,64,67,71,75],"span",{"class":62,"style":63},"line","display: inline",[60,65,53],{"style":66},"color:#6F42C1;--shiki-dark:#B392F0",[60,68,70],{"style":69},"color:#032F62;--shiki-dark:#9ECBFF"," add",[60,72,74],{"style":73},"color:#005CC5;--shiki-dark:#79B8FF"," -d",[60,76,77],{"style":69}," @kubb\u002Fplugin-cypress",[50,79,82],{"language":52,"filename":80,"code":81,"class":55},"pnpm","pnpm add -D @kubb\u002Fplugin-cypress",[14,83,84],{"class":58},[60,85,86,88,90,93],{"class":62,"style":63},[60,87,80],{"style":66},[60,89,70],{"style":69},[60,91,92],{"style":73}," -D",[60,94,77],{"style":69},[50,96,99],{"language":52,"filename":97,"code":98,"class":55},"npm","npm install --save-dev @kubb\u002Fplugin-cypress",[14,100,101],{"class":58},[60,102,103,105,108,111],{"class":62,"style":63},[60,104,97],{"style":66},[60,106,107],{"style":69}," install",[60,109,110],{"style":73}," --save-dev",[60,112,77],{"style":69},[50,114,117],{"language":52,"filename":115,"code":116,"class":55},"yarn","yarn add -D @kubb\u002Fplugin-cypress",[14,118,119],{"class":58},[60,120,121,123,125,127],{"class":62,"style":63},[60,122,115],{"style":66},[60,124,70],{"style":69},[60,126,92],{"style":73},[60,128,77],{"style":69},[10,130,131,132,135,136,141,142,145,146,39],{},"Or run ",[14,133,134],{},"kubb add plugin-cypress"," to install the version the ",[137,138,140],"a",{"href":139},"\u002Fregistry","Kubb registry"," pins and add ",[14,143,144],{},"pluginCypress()"," to ",[14,147,148],{},"kubb.config.ts",[41,150,152],{"id":151},"setup","Setup",[154,155,156,164,171],"ul",{},[157,158,159,160,163],"li",{},"Add ",[14,161,162],{},"@kubb\u002Fplugin-ts"," for the request and response types.",[157,165,166,167,170],{},"Install ",[14,168,169],{},"cypress"," v15 or v16 in the project that runs the tests.",[157,172,159,173,176,177,179],{},[14,174,175],{},"\"types\": [\"cypress\"]"," to the tsconfig that covers the generated files, because the helpers use the global ",[14,178,5],{}," namespace.",[41,181,183],{"id":182},"options-worth-knowing","Options worth knowing",[154,185,186],{},[157,187,188,191,192,39],{},[14,189,190],{},"baseURL"," is prepended to every request. Without it, Cypress resolves the path against its own ",[14,193,194],{},"baseUrl",[10,196,197,198,202],{},"See ",[137,199,201],{"href":200},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-cypress\u002Foptions","Options"," for every option and its default.",[41,204,206],{"id":205},"example","Example",[10,208,209,210,39],{},"The config below writes the helpers to ",[14,211,212],{},"src\u002Fgen\u002Fcypress",[50,214,217],{"language":215,"filename":148,"code":216,"class":55},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\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  plugins: [\n    pluginTs(),\n    pluginCypress({ output: { path: 'cypress', mode: 'directory' } }),\n  ],\n})",[14,218,220,236,237,236,249,236,261,236,263,236,277,236,288,236,299,236,304,236,312,236,332,236,337],{"class":219},"language-typescript",[60,221,222,226,230,233],{"class":62,"style":63},[60,223,225],{"style":224},"color:#D73A49;--shiki-dark:#F97583","import",[60,227,229],{"style":228},"color:#24292E;--shiki-dark:#E1E4E8"," { defineConfig } ",[60,231,232],{"style":224},"from",[60,234,235],{"style":69}," 'kubb\u002Fconfig'","\n",[60,238,239,241,244,246],{"class":62,"style":63},[60,240,225],{"style":224},[60,242,243],{"style":228}," { pluginTs } ",[60,245,232],{"style":224},[60,247,248],{"style":69}," '@kubb\u002Fplugin-ts'",[60,250,251,253,256,258],{"class":62,"style":63},[60,252,225],{"style":224},[60,254,255],{"style":228}," { pluginCypress } ",[60,257,232],{"style":224},[60,259,260],{"style":69}," '@kubb\u002Fplugin-cypress'",[60,262],{"class":62,"style":63},[60,264,265,268,271,274],{"class":62,"style":63},[60,266,267],{"style":224},"export",[60,269,270],{"style":224}," default",[60,272,273],{"style":66}," defineConfig",[60,275,276],{"style":228},"({",[60,278,279,282,285],{"class":62,"style":63},[60,280,281],{"style":228},"  input: ",[60,283,284],{"style":69},"'.\u002FpetStore.yaml'",[60,286,287],{"style":228},",",[60,289,290,293,296],{"class":62,"style":63},[60,291,292],{"style":228},"  output: { path: ",[60,294,295],{"style":69},"'.\u002Fsrc\u002Fgen'",[60,297,298],{"style":228}," },",[60,300,301],{"class":62,"style":63},[60,302,303],{"style":228},"  plugins: [",[60,305,306,309],{"class":62,"style":63},[60,307,308],{"style":66},"    pluginTs",[60,310,311],{"style":228},"(),",[60,313,314,317,320,323,326,329],{"class":62,"style":63},[60,315,316],{"style":66},"    pluginCypress",[60,318,319],{"style":228},"({ output: { path: ",[60,321,322],{"style":69},"'cypress'",[60,324,325],{"style":228},", mode: ",[60,327,328],{"style":69},"'directory'",[60,330,331],{"style":228}," } }),",[60,333,334],{"class":62,"style":63},[60,335,336],{"style":228},"  ],",[60,338,339],{"class":62,"style":63},[60,340,341],{"style":228},"})",[10,343,344,345,348,349,352,353,39],{},"A test then calls a helper and gets a typed response body. ",[14,346,347],{},"petId"," is an ",[14,350,351],{},"int64",", which the default adapter types as ",[14,354,355],{},"bigint",[50,357,360],{"language":215,"filename":358,"code":359,"class":55},"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: 1n } }).then((pet) => {\n      expect(pet.name).to.be.a('string')\n    })\n  })\n})",[14,361,362,236,374,236,376,236,396,236,412,236,446,236,464,236,469,236,474],{"class":219},[60,363,364,366,369,371],{"class":62,"style":63},[60,365,225],{"style":224},[60,367,368],{"style":228}," { getPetById } ",[60,370,232],{"style":224},[60,372,373],{"style":69}," '..\u002F..\u002Fsrc\u002Fgen\u002Fcypress\u002FgetPetById'",[60,375],{"class":62,"style":63},[60,377,378,381,384,387,390,393],{"class":62,"style":63},[60,379,380],{"style":66},"describe",[60,382,383],{"style":228},"(",[60,385,386],{"style":69},"'Pet API'",[60,388,389],{"style":228},", () ",[60,391,392],{"style":224},"=>",[60,394,395],{"style":228}," {",[60,397,398,401,403,406,408,410],{"class":62,"style":63},[60,399,400],{"style":66},"  it",[60,402,383],{"style":228},[60,404,405],{"style":69},"'returns the pet by id'",[60,407,389],{"style":228},[60,409,392],{"style":224},[60,411,395],{"style":228},[60,413,414,417,420,423,426,429,432,435,439,442,444],{"class":62,"style":63},[60,415,416],{"style":66},"    getPetById",[60,418,419],{"style":228},"({ path: { petId: ",[60,421,422],{"style":73},"1",[60,424,425],{"style":224},"n",[60,427,428],{"style":228}," } }).",[60,430,431],{"style":66},"then",[60,433,434],{"style":228},"((",[60,436,438],{"style":437},"color:#E36209;--shiki-dark:#FFAB70","pet",[60,440,441],{"style":228},") ",[60,443,392],{"style":224},[60,445,395],{"style":228},[60,447,448,451,454,456,458,461],{"class":62,"style":63},[60,449,450],{"style":66},"      expect",[60,452,453],{"style":228},"(pet.name).to.be.",[60,455,137],{"style":66},[60,457,383],{"style":228},[60,459,460],{"style":69},"'string'",[60,462,463],{"style":228},")",[60,465,466],{"class":62,"style":63},[60,467,468],{"style":228},"    })",[60,470,471],{"class":62,"style":63},[60,472,473],{"style":228},"  })",[60,475,476],{"class":62,"style":63},[60,477,341],{"style":228},{"title":479,"searchDepth":480,"depth":480,"links":481},"",5,[482,484,485,486],{"id":43,"depth":483,"text":44},2,{"id":151,"depth":483,"text":152},{"id":182,"depth":483,"text":183},{"id":205,"depth":483,"text":206},"md",{},{},true,null,"\u002Fextensions\u002Fkubb-labs\u002Fplugin-cypress",{"title":5},{"loc":492},"extensions\u002Fkubb-labs\u002Fplugin-cypress\u002Findex","ndVSWU78ng9Cnj5cKe4Ee6qNE3vHF26iNGsImaSpj1c",false,1792782251252]