Officialv5.0.8MITkubb >=5.0.0node >=22
@kubb/plugin-cypress
Generates a typed cy.request() wrapper per OpenAPI operation so your Cypress tests call the API through generated helpers and catch broken calls at compile time.
cypresse2e-testingapi-testingtest-generationcodegenopenapi
- Downloads
- 32.2K/ mo
- Stars
- 8
- Bundle size
- 142.6 kB
- Updated
- 39m ago
Generate typed cy.request() helpers from OpenAPI.
- Grouped
body,path,query, andheadersparameters named after the spec. - Response bodies typed as
Cypress.Chainable<{Operation}Response>.
Installation
bun add -d @kubb/plugin-cypresspnpm add -D @kubb/plugin-cypressnpm install --save-dev @kubb/plugin-cypressyarn add -D @kubb/plugin-cypressOr run kubb add plugin-cypress to install the version the Kubb registry pins and add pluginCypress() to kubb.config.ts.
Dependencies
- Add
pluginTsfor request and response types. - Generated helpers require Cypress v13 or higher.
Example
kubb.config.ts
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginCypress } from '@kubb/plugin-cypress'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
plugins: [
pluginTs(),
pluginCypress({ output: { path: 'cypress', mode: 'directory' } }),
],
})pet.cy.ts
import { getPetById } from '../src/gen/cypress/getPetById'
describe('Pet API', () => {
it('returns the pet by id', () => {
getPetById({ path: { petId: 1n } }).then((pet) => {
expect(pet.id).to.eq(1n)
})
})
})