@kubb/plugin-cypress 5.3.2 → 5.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/docs/options.md +16 -28
- package/docs/overview.md +25 -7
- package/kubb-extension.json +2 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -527,11 +527,11 @@ const cypressGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
527
527
|
});
|
|
528
528
|
// kubb-extension.json
|
|
529
529
|
var compatibility = {
|
|
530
|
-
"kubb": ">=5.
|
|
530
|
+
"kubb": ">=5.19.0",
|
|
531
531
|
"node": ">=22.22"
|
|
532
532
|
};
|
|
533
533
|
// package.json
|
|
534
|
-
var version = "5.3.
|
|
534
|
+
var version = "5.3.4";
|
|
535
535
|
// src/resolvers/resolverCypress.ts
|
|
536
536
|
/**
|
|
537
537
|
* Default resolver used by `@kubb/plugin-cypress`. Decides the names and file
|
package/dist/index.js
CHANGED
|
@@ -523,11 +523,11 @@ const cypressGenerator = defineGenerator({
|
|
|
523
523
|
});
|
|
524
524
|
// kubb-extension.json
|
|
525
525
|
var compatibility = {
|
|
526
|
-
"kubb": ">=5.
|
|
526
|
+
"kubb": ">=5.19.0",
|
|
527
527
|
"node": ">=22.22"
|
|
528
528
|
};
|
|
529
529
|
// package.json
|
|
530
|
-
var version = "5.3.
|
|
530
|
+
var version = "5.3.4";
|
|
531
531
|
// src/resolvers/resolverCypress.ts
|
|
532
532
|
/**
|
|
533
533
|
* Default resolver used by `@kubb/plugin-cypress`. Decides the names and file
|
package/docs/options.md
CHANGED
|
@@ -1,44 +1,32 @@
|
|
|
1
1
|
# Options
|
|
2
2
|
|
|
3
|
-
Pass these options to `pluginCypress()`. Shared options link to [Shared plugin options](https://kubb.dev/docs/5.x/reference/plugin-options).
|
|
3
|
+
Pass these options to `pluginCypress()`. Shared options link to [Shared plugin options](https://kubb.dev/docs/5.x/reference/plugin-options), and this page gives only their default here.
|
|
4
4
|
|
|
5
5
|
## Options overview
|
|
6
6
|
|
|
7
|
-
| Option | Purpose
|
|
8
|
-
| ------------------------------------------------------------------------- |
|
|
9
|
-
| [`output`](https://kubb.dev/docs/5.x/reference/plugin-options#output) | Where files are written
|
|
10
|
-
| [`group`](https://kubb.dev/docs/5.x/reference/plugin-options#group) | Split output by tag or path
|
|
11
|
-
| [`baseURL`](#baseurl) | Base URL prepended to every request.
|
|
12
|
-
| [`include`](https://kubb.dev/docs/5.x/reference/plugin-options#include) | Keep only operations that match.
|
|
13
|
-
| [`exclude`](https://kubb.dev/docs/5.x/reference/plugin-options#exclude) | Skip operations that match.
|
|
14
|
-
| [`override`](https://kubb.dev/docs/5.x/reference/plugin-options#override) | Apply different options per pattern.
|
|
15
|
-
| [`resolver`](https://kubb.dev/docs/5.x/reference/plugin-options#resolver) | Customize generated names and file paths.
|
|
16
|
-
| [`macros`](https://kubb.dev/docs/5.x/reference/plugin-options#macros) | Rewrite AST nodes before printing.
|
|
17
|
-
|
|
18
|
-
`resolverCypress` adds no namespaces of its own, so a `resolver` patch uses only the shared `name`, `file` and `imports` members.
|
|
7
|
+
| Option | Purpose | Default |
|
|
8
|
+
| ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
|
9
|
+
| [`output`](https://kubb.dev/docs/5.x/reference/plugin-options#output) | Where files are written. | `{ path: 'cypress', barrel: { type: 'named' } }` |
|
|
10
|
+
| [`group`](https://kubb.dev/docs/5.x/reference/plugin-options#group) | Split output by tag or path. | None |
|
|
11
|
+
| [`baseURL`](#baseurl) | Base URL prepended to every request. | None |
|
|
12
|
+
| [`include`](https://kubb.dev/docs/5.x/reference/plugin-options#include) | Keep only operations that match. | None |
|
|
13
|
+
| [`exclude`](https://kubb.dev/docs/5.x/reference/plugin-options#exclude) | Skip operations that match. | `[]` |
|
|
14
|
+
| [`override`](https://kubb.dev/docs/5.x/reference/plugin-options#override) | Apply different options per pattern. | `[]` |
|
|
15
|
+
| [`resolver`](https://kubb.dev/docs/5.x/reference/plugin-options#resolver) | Customize generated names and file paths. `resolverCypress` adds no members of its own. | `resolverCypress` |
|
|
16
|
+
| [`macros`](https://kubb.dev/docs/5.x/reference/plugin-options#macros) | Rewrite AST nodes before printing. | `[]` |
|
|
19
17
|
|
|
20
18
|
## Option details
|
|
21
19
|
|
|
22
20
|
### baseURL
|
|
23
21
|
|
|
24
|
-
Base URL
|
|
22
|
+
Base URL that Kubb writes into each helper's request URL, so no runtime setup is needed. The adapter's server URL is not used.
|
|
25
23
|
|
|
26
24
|
| | |
|
|
27
25
|
| -------- | -------- |
|
|
28
26
|
| Type | `string` |
|
|
29
27
|
| Required | `false` |
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
): Cypress.Chainable<ShowPetByIdResponse> {
|
|
36
|
-
return cy
|
|
37
|
-
.request<ShowPetByIdResponse>({
|
|
38
|
-
method: 'GET',
|
|
39
|
-
url: `https://staging.petstore.dev/pets/${path.petId}`,
|
|
40
|
-
...options,
|
|
41
|
-
})
|
|
42
|
-
.then((res) => res.body)
|
|
43
|
-
}
|
|
44
|
-
```
|
|
29
|
+
| Value | Helper URL | Resolved by |
|
|
30
|
+
| -------------------------------- | ------------------------------------------------------- | ---------------------------------- |
|
|
31
|
+
| None (default) | `` `/pets/${path.petId}` `` | Cypress, against its own `baseUrl` |
|
|
32
|
+
| `'https://staging.petstore.dev'` | `` `https://staging.petstore.dev/pets/${path.petId}` `` | The helper |
|
package/docs/overview.md
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
# Cypress
|
|
2
2
|
|
|
3
|
-
The Cypress plugin generates a typed `cy.request()` helper for each operation in your OpenAPI spec.
|
|
3
|
+
The Cypress plugin generates a typed `cy.request()` helper for each operation in your OpenAPI spec. A helper returns `Cypress.Chainable<{Operation}Response>`.
|
|
4
4
|
|
|
5
|
-
Each helper takes grouped `path`, `query`, `headers`, and `body` parameters named after the spec.
|
|
5
|
+
Each helper takes grouped `path`, `query`, `headers`, `cookies`, and `body` parameters named after the spec.
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
9
9
|
- Add `@kubb/plugin-ts` for the request and response types.
|
|
10
10
|
- Install `cypress` v15 or v16 in the project that runs the tests.
|
|
11
|
-
- Add `"types": ["cypress"]` to the tsconfig that covers the generated files
|
|
11
|
+
- Add `"types": ["cypress"]` to the tsconfig that covers the generated files. The helpers use the global `Cypress` namespace.
|
|
12
12
|
|
|
13
13
|
## Options worth knowing
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
| Option | Default | What it does |
|
|
16
|
+
| --------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------- |
|
|
17
|
+
| [`baseURL`](https://kubb.dev/extensions/kubb-labs/plugin-cypress/options#baseurl) | None | Prepends a host. Without it, Cypress resolves the path against its own `baseUrl`. |
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
The other options are the [shared plugin options](https://kubb.dev/docs/5.x/reference/plugin-options).
|
|
18
20
|
|
|
19
21
|
## Example
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
This config writes the helpers to `src/gen/cypress`. `contentType` keeps the JSON response of the Petstore spec, which also declares XML, so bodies are not typed as `Pet | string`. `integerType: 'number'` types the `int64` `petId` as `number`.
|
|
24
|
+
|
|
25
|
+
::code-group
|
|
22
26
|
|
|
23
27
|
```typescript [kubb.config.ts]
|
|
24
28
|
import { defineConfig } from 'kubb/config'
|
|
@@ -37,7 +41,19 @@ export default defineConfig({
|
|
|
37
41
|
})
|
|
38
42
|
```
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
```typescript [src/gen/cypress/getPetById.ts]
|
|
45
|
+
import type { GetPetByIdOptions, GetPetByIdResponse } from '../types/GetPetById'
|
|
46
|
+
|
|
47
|
+
export function getPetById({ path }: GetPetByIdOptions, options: Partial<Cypress.RequestOptions> = {}): Cypress.Chainable<GetPetByIdResponse> {
|
|
48
|
+
return cy
|
|
49
|
+
.request<GetPetByIdResponse>({
|
|
50
|
+
method: 'GET',
|
|
51
|
+
url: `/pet/${path.petId}`,
|
|
52
|
+
...options,
|
|
53
|
+
})
|
|
54
|
+
.then((res) => res.body) as Cypress.Chainable<GetPetByIdResponse>
|
|
55
|
+
}
|
|
56
|
+
```
|
|
41
57
|
|
|
42
58
|
```typescript [cypress/e2e/pet.cy.ts]
|
|
43
59
|
import { getPetById } from '../../src/gen/cypress/getPetById'
|
|
@@ -50,3 +66,5 @@ describe('Pet API', () => {
|
|
|
50
66
|
})
|
|
51
67
|
})
|
|
52
68
|
```
|
|
69
|
+
|
|
70
|
+
::
|
package/kubb-extension.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "plugin-cypress",
|
|
5
5
|
"export": "pluginCypress",
|
|
6
6
|
"displayName": "Cypress",
|
|
7
|
-
"description": "Generates a typed cy.request() wrapper per OpenAPI operation so your Cypress tests call the API through
|
|
7
|
+
"description": "Generates a typed cy.request() wrapper per OpenAPI operation, so your Cypress tests call the API through helpers and catch broken calls at compile time.",
|
|
8
8
|
"category": "testing",
|
|
9
9
|
"icon": {
|
|
10
10
|
"light": "https://kubb.dev/feature/cypress.svg"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": ["plugin-ts"],
|
|
21
21
|
"compatibility": {
|
|
22
|
-
"kubb": ">=5.
|
|
22
|
+
"kubb": ">=5.19.0",
|
|
23
23
|
"node": ">=22.22"
|
|
24
24
|
},
|
|
25
25
|
"options": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-cypress",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.4",
|
|
4
4
|
"description": "Generate Cypress request commands and e2e test fixtures with Kubb for automated API testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-generation",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"registry": "https://registry.npmjs.org/"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@kubb/kit": "^5.
|
|
72
|
-
"@kubb/plugin-ts": "^5.5.
|
|
73
|
-
"@kubb/renderer-jsx": "^5.
|
|
71
|
+
"@kubb/kit": "^5.20.1",
|
|
72
|
+
"@kubb/plugin-ts": "^5.5.4",
|
|
73
|
+
"@kubb/renderer-jsx": "^5.20.1"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@internals/shared": "0.0.0",
|