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