plugins: [pluginCypress()]Cypress
@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.
- Downloads32.2K/ monthnpm, last 30 days
- GitHub stars8kubb-labs/plugins
- Unpacked size147.1kBv5.0.10 on npm
- Latest release9h agov5.0.10 · Oct 13, 2026
The Cypress plugin generates a typed cy.request() helper for each operation in your OpenAPI spec.
Each helper takes grouped path, query, headers, and body parameters named after the spec. It returns the response body 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.
Setup
- Add
@kubb/plugin-tsfor the request and response types. - Install
cypressv15 or v16 in the project that runs the tests. - Add
"types": ["cypress"]to the tsconfig that covers the generated files, because the helpers use the globalCypressnamespace.
Options worth knowing
baseURLis prepended to every request. Without it, Cypress resolves the path against its ownbaseUrl.
See Options for every option and its default.
Example
The config below writes the helpers to src/gen/cypress.
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' } }),
],
})A test then calls a helper and gets a typed response body. petId is an int64, which the default adapter types as bigint.
import { getPetById } from '../../src/gen/cypress/getPetById'
describe('Pet API', () => {
it('returns the pet by id', () => {
getPetById({ path: { petId: 1n } }).then((pet) => {
expect(pet.name).to.be.a('string')
})
})
})Dependencies
Extensions that must be in the same config as Cypress.