UNPKG

@kubb/plugin-cypress

Version:

Cypress test generator plugin for Kubb, creating end-to-end tests from OpenAPI specifications for automated API testing.

84 lines (79 loc) 2.77 kB
import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core' import type { contentType, Oas } from '@kubb/oas' import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas' import type { Generator } from '@kubb/plugin-oas/generators' export type Options = { /** * Specify the export location for the files and define the behavior of the output * @default { path: 'cypress', barrelType: 'named' } */ output?: Output<Oas> /** * Define which contentType should be used. * By default, the first JSON valid mediaType will be used */ contentType?: contentType /** * ReturnType that will be used when calling cy.request. * - 'data' will return ResponseConfig[data]. * - 'full' will return ResponseConfig. * @default 'data' */ dataReturnType?: 'data' | 'full' /** * How to style your params, by default no casing is applied * - 'camelcase' will use camelcase for the params names */ paramsCasing?: 'camelcase' /** * How to pass your params * - 'object' will return the params and pathParams as an object. * - 'inline' will return the params as comma separated params. * @default 'inline' */ paramsType?: 'object' | 'inline' /** * How to pass your pathParams. * - 'object' will return the pathParams as an object. * - 'inline' will return the pathParams as comma separated params. * @default 'inline' */ pathParamsType?: 'object' | 'inline' baseURL?: string /** * Group the Cypress requests based on the provided name. */ group?: Group /** * Array containing exclude parameters to exclude/skip tags/operations/methods/paths. */ exclude?: Array<Exclude> /** * Array containing include parameters to include tags/operations/methods/paths. */ include?: Array<Include> /** * Array containing override parameters to override `options` based on tags/operations/methods/paths. */ override?: Array<Override<ResolvedOptions>> transformers?: { /** * Customize the names based on the type that is provided by the plugin. */ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string } /** * Define some generators next to the Cypress generators. */ generators?: Array<Generator<PluginCypress>> } type ResolvedOptions = { output: Output<Oas> group: Options['group'] baseURL: Options['baseURL'] | undefined dataReturnType: NonNullable<Options['dataReturnType']> pathParamsType: NonNullable<Options['pathParamsType']> paramsType: NonNullable<Options['paramsType']> paramsCasing: Options['paramsCasing'] } export type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions>