Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit dfa5f55

Browse files
committed
refactor: optimize cypress configuration
1 parent df50231 commit dfa5f55

File tree

75 files changed

+5160
-5223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5160
-5223
lines changed

@types/components.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* Typescript support for @chakra-ui/vue-next2.1.0-beta.10 auto-imported
2+
* Typescript support for @chakra-ui/vue-next2.1.0-beta.11 auto-imported
33
* components using `unplugin-vue-components,`
44
*
55
* @see: https://github.com/antfu/unplugin-vue-components/#typescript
66
*
77
* This is a generated file. Do not edit it's contents.
88
*
9-
* This file was generated on 2023-03-28T18:38:28.043Z
9+
* This file was generated on 2023-04-22T14:04:49.473Z
1010
*/
1111

1212
import { ChakraProps, chakra } from "@chakra-ui/vue-system"

@types/cypress-shims.d.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

@types/cypress.d.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/// <reference types="cypress" />
2+
3+
import { mount } from "cypress/vue"
4+
5+
import type { mount as cyMount } from "cypress/vue"
6+
import type { MountingOptions, VueWrapper } from "@vue/test-utils"
7+
import type {
8+
AllowedComponentProps,
9+
ComponentPublicInstance,
10+
FunctionalComponent,
11+
VNodeProps,
12+
} from "vue"
13+
14+
type Swipe = number[] | string
15+
16+
type StripProps =
17+
| keyof VNodeProps
18+
| keyof AllowedComponentProps
19+
| "v-slots"
20+
| "$children"
21+
| `v-slot:${string}`
22+
23+
type Events<T> = T extends { $props: infer P extends object }
24+
? {
25+
[K in Exclude<keyof P, StripProps> as K extends `on${infer N}`
26+
? Uncapitalize<N>
27+
: never]: P[K] extends ((...args: any[]) => any) | undefined
28+
? Parameters<NonNullable<P[K]>>[]
29+
: never
30+
}
31+
: never
32+
33+
type MountParams = Parameters<typeof mount>
34+
type OptionsParam = MountParams[1]
35+
36+
declare global {
37+
namespace Cypress {
38+
interface Chainable {
39+
mount: typeof mount
40+
emitted<
41+
T extends new (...args: any) => any,
42+
E extends Events<InstanceType<T>>,
43+
K extends keyof E
44+
>(
45+
selector: T,
46+
event?: K
47+
): Chainable<E[K]>
48+
/**
49+
* Run a11y tests or only a subset of all tests
50+
* @see https://github.com/avanslaars/cypress-axe
51+
* @example
52+
* cy.checkA11y()
53+
*/
54+
checkA11y(options?: any, params?: object): Chainable
55+
/**
56+
* Triggers tab action
57+
* @param options
58+
*/
59+
tab(options?: { shift: boolean }): Chainable
60+
}
61+
}
62+
}
63+
64+
declare module "cypress/vue" {
65+
export function mount(
66+
component: JSX.Element,
67+
options?: MountingOptions<any> | null
68+
): Cypress.Chainable
69+
}

@types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import "./components"
2-
import "./cypress-shims"
2+
import "./cypress"
33
import "./env"
44
import "./vue-shims"

components.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* Typescript support for @chakra-ui/vue-next2.1.0-beta.10 auto-imported
2+
* Typescript support for @chakra-ui/vue-next2.1.0-beta.11 auto-imported
33
* components using `unplugin-vue-components,`
44
*
55
* @see: https://github.com/antfu/unplugin-vue-components/#typescript
66
*
77
* This is a generated file. Do not edit it's contents.
88
*
9-
* This file was generated on 2023-03-28T18:38:28.043Z
9+
* This file was generated on 2023-04-22T14:04:49.473Z
1010
*/
1111

1212
import { ChakraProps, chakra } from "@chakra-ui/vue-system"

cypress.d.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { mount } from "cypress/vue"
2+
3+
import type { mount as cyMount } from "cypress/vue"
4+
import type { MountingOptions, VueWrapper } from "@vue/test-utils"
5+
import type {
6+
AllowedComponentProps,
7+
ComponentPublicInstance,
8+
FunctionalComponent,
9+
VNodeProps,
10+
} from "vue"
11+
12+
type Swipe = number[] | string
13+
14+
type StripProps =
15+
| keyof VNodeProps
16+
| keyof AllowedComponentProps
17+
| "v-slots"
18+
| "$children"
19+
| `v-slot:${string}`
20+
21+
type Events<T> = T extends { $props: infer P extends object }
22+
? {
23+
[K in Exclude<keyof P, StripProps> as K extends `on${infer N}`
24+
? Uncapitalize<N>
25+
: never]: P[K] extends ((...args: any[]) => any) | undefined
26+
? Parameters<NonNullable<P[K]>>[]
27+
: never
28+
}
29+
: never
30+
31+
type MountParams = Parameters<typeof mount>
32+
type OptionsParam = MountParams[1]
33+
34+
declare global {
35+
namespace Cypress {
36+
interface Chainable {
37+
mount: typeof mount
38+
emitted<
39+
T extends new (...args: any) => any,
40+
E extends Events<InstanceType<T>>,
41+
K extends keyof E
42+
>(
43+
selector: T,
44+
event?: K
45+
): Chainable<E[K]>
46+
}
47+
}
48+
}
49+
50+
declare module "cypress/vue" {
51+
export function mount(
52+
component: JSX.Element,
53+
options?: MountingOptions<any> | null
54+
): Cypress.Chainable
55+
}

cypress/support/component.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,13 @@ import "./commands"
2222
// require('./commands')
2323

2424
import { mount } from "cypress/vue"
25-
import Chakra, {
26-
chakra,
27-
extendTheme,
28-
extendChakra,
29-
CReset,
30-
} from "../../packages/vue"
31-
import { mode } from "@chakra-ui/theme-tools"
25+
import { createChakra, chakra, extendTheme } from "../../packages/vue"
3226
import { feActivity, feUser } from "feather-icons-paths"
33-
import { h, Fragment, defineComponent } from "vue"
34-
35-
import { domElements } from "../../packages/system"
3627

3728
import { MotionPlugin } from "@vueuse/motion"
3829
import "./env"
3930

40-
const chakraOptions = extendChakra({
31+
const chakra = createChakra({
4132
cssReset: true,
4233
icons: {
4334
library: {
@@ -56,15 +47,10 @@ Cypress.Commands.add("mount", (component, options = {}) => {
5647
options.global.plugins.push({
5748
install(app) {
5849
app.use(MotionPlugin)
59-
app.use(Chakra, chakraOptions)
50+
app.use(chakra)
6051
},
6152
})
6253

63-
domElements.forEach((tag) => {
64-
// @ts-ignore
65-
options.global.components[`chakra?.${tag}`] = chakra(tag)
66-
})
67-
6854
// <component> is a built-in component that comes with Vue
6955
// @ts-ignore
7056
return mount(component, options)

cypress/support/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/// <reference types="cypress" />
22
/// <reference types="./vue-shims" />
33

4-
import { ChakraProps } from "@chakra-ui/vue-system"
5-
import { mount } from "@cypress/vue"
6-
import type { MountingOptions } from "cypress/vue/dist/@vue/test-utils"
4+
import { StyleAndHTMLAttibutes } from "@chakra-ui/vue-next"
5+
import { mount } from "cypress/vue"
6+
import type { MountingOptions, VueWrapper } from "@vue/test-utils"
77

88
// cypress/support/index.ts
99
declare global {
@@ -26,7 +26,7 @@ declare global {
2626
}
2727
}
2828
namespace JSX {
29-
interface IntrinsicAttributes extends ChakraProps {}
29+
interface IntrinsicAttributes extends StyleAndHTMLAttibutes {}
3030
}
3131
}
3232

cypress/tsconfig.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2-
"extends": "../tsconfig.json",
3-
"include": ["**/*.ts", "../cypress.d.ts"]
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["es5", "dom"],
5+
"types": ["cypress", "node"]
6+
},
7+
"include": ["**/*.ts", "**/*.cy.tsx", "support/types.ts"]
48
}

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@
8989
"@commitlint/cli": "^11.0.0",
9090
"@commitlint/config-conventional": "^11.0.0",
9191
"@ctrl/tinycolor": "^3.4.1",
92-
"@cypress/vite-dev-server": "^5.0.2",
93-
"@cypress/vue": "^5.0.3",
9492
"@emotion/css": "^11.10.6",
9593
"@emotion/jest": "^11.7.1",
9694
"@emotion/server": "^11.10.0",
@@ -134,7 +132,6 @@
134132
"@vue/runtime-core": "3.2.47",
135133
"@vue/runtime-dom": "3.2.47",
136134
"@vue/server-renderer": "3.2.47",
137-
"@vue/test-utils": "^2.2.7",
138135
"@vue/tsconfig": "^0.1.3",
139136
"@vuedx/typecheck": "^0.4.1",
140137
"@vuedx/typescript-plugin-vue": "^0.4.1",
@@ -156,7 +153,6 @@
156153
"cross-env": "^7.0.2",
157154
"css-get-unit": "^1.0.1",
158155
"csstype": "^3.1.1",
159-
"cypress": "12",
160156
"dequal": "^2.0.2",
161157
"dom-focus-lock": "^1.0.4",
162158
"esbuild": "0.13.4",
@@ -240,6 +236,8 @@
240236
}
241237
},
242238
"devDependencies": {
243-
"clean-package": "^2.2.0"
239+
"@vue/test-utils": "^2.2.7",
240+
"clean-package": "^2.2.0",
241+
"cypress": "^12.10.0"
244242
}
245243
}

0 commit comments

Comments
 (0)