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

Commit 7d01cd9

Browse files
committed
test(cypress): testing workflow in ci
1 parent de85a27 commit 7d01cd9

File tree

57 files changed

+122
-119
lines changed

Some content is hidden

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

57 files changed

+122
-119
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,19 @@ with [Jest](), which is mostly used for black-box testing.
235235

236236
#### Testing with Cypress
237237

238-
1. Create your `<COMPONENT>.cy.tsx` file in the `packages/<COMPONENT>/tests/`
239-
directory; where `<COMPONENT>` is the name of the component you are testing.
238+
1. Create your `<COMPONENT>.cy.tsx` file in the
239+
`packages/<COMPONENT>/tests/component/` directory; where `<COMPONENT>` is the
240+
name of the component you are testing. **Please take note that the Cypress
241+
tests are to be put under the `tests/component/**` directory. This is to
242+
prevent type conflicts between Jest and Cypress globals.
240243
2. Add the Cypress type references at the top of the file as shown in the
241244
example below. This will allow typescript to correctly reference the Cypress
242245
globals.
243246

244247
```tsx
245-
/// <reference types="../../../@types/cypress" />
248+
/// <reference types="../../../../@types/cypress" />
246249

247-
import { MyComponent } from "../src/my-component"
250+
import { MyComponent } from "../../src/my-component"
248251

249252
it("<MyComponent /> is accessible", () => {
250253
cy.mount(() => <MyComponent>Hello World</MyComponent>)

cypress.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from "cypress"
22

33
export default defineConfig({
4+
projectId: 'rb8e7m',
45
video: false,
56
fixturesFolder: false,
67
reporter: "spec",

cypress/support/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* This file should be replaced with cypress-axe
55
* once that package becomes esm-compatible
66
*/
7+
// @ts-ignore
78
import axeCore from "axe-core"
89

910
axeCore.configure({

cypress/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2+
"extends": "../tsconfig.json",
23
"compilerOptions": {
34
"target": "es5",
45
"lib": ["es5", "dom"],
5-
"types": ["cypress", "node"]
6+
"types": ["node"]
67
},
78
"include": ["**/*.ts", "**/*.cy.tsx", "support/types.ts"]
89
}

packages/c-accordion/tests/c-accordion.cy.tsx renamed to packages/c-accordion/tests/component/c-accordion.cy.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/// <reference types="../../../@types/cypress" />
1+
/// <reference types="../../../../@types/cypress" />
22

3-
import { CAccordion } from "../src"
3+
import { CAccordion } from "../../src"
44
import { h } from "vue"
55

66
it("should render properly", () => {

packages/c-alert/tests/c-alert.cy.tsx renamed to packages/c-alert/tests/component/c-alert.cy.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/// <reference types="../../../@types/cypress" />
1+
/// <reference types="../../../../@types/cypress" />
22

3-
import * as Examples from "../examples"
3+
import * as Examples from "../../examples"
44
import { h } from "vue"
5-
import { CAlert, CAlertDescription, CAlertIcon, CAlertTitle } from "../src"
5+
import { CAlert, CAlertDescription, CAlertIcon, CAlertTitle } from "../../src"
66

77
describe("Alert Examples", () => {
88
Object.entries(Examples).map(([name, example]) => {

packages/c-avatar/tests/c-avatar-badge.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render, waitMs } from "../../test-utils/src"
1+
import { render, waitMs } from "@chakra-ui/vue-test-utils"
22
import { CAvatar, CAvatarBadge, avatarProps } from "../src"
33

44
const renderAvatar = (props?: any) => {

packages/c-avatar/tests/c-avatar-group.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render } from "../../test-utils/src"
1+
import { render } from "@chakra-ui/vue-test-utils"
22
import { CAvatar, CAvatarGroup, avatarGroupProps } from "../src"
33

44
interface AvatarOptions {

packages/c-avatar/tests/c-avatar.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render, waitMs } from "../../test-utils/src"
1+
import { render, waitMs } from "@chakra-ui/vue-test-utils"
22
import { CAvatar, avatarProps } from "../src"
33

44
const renderAvatar = (props?: any) => {
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/// <reference types="../../../@types/cypress" />
1+
/// <reference types="../../../../@types/cypress" />
22
import { h, ref } from "vue"
33

4-
import { CAvatar } from "../src"
5-
import * as Examples from "../examples"
4+
import { CAvatar } from "../../src"
5+
import * as Examples from "../../examples"
66

77
describe("CAvatar", () => {
88
it("has no accessibility violation", () => {
@@ -15,13 +15,11 @@ describe("CAvatar", () => {
1515

1616
it("renders with default svg", () => {
1717
cy.mount(() => h(CAvatar))
18-
1918
cy.get("svg")
2019
})
2120

2221
it("render initials by default when name is specified", () => {
2322
cy.mount(() => h(() => <CAvatar name="Hello World" />))
24-
2523
cy.contains("HW")
2624
})
2725

@@ -36,18 +34,11 @@ describe("CAvatar", () => {
3634
)
3735

3836
cy.contains("HW")
39-
4037
cy.get("img:visible")
4138
})
4239

4340
it("renders default svg when name is not specified", () => {
44-
cy.mount(() =>
45-
h(() => (
46-
<CAvatar src="https://avatars.githubusercontent.com/u/21237954?v=4" />
47-
))
48-
)
49-
41+
cy.mount(() => h(() => <CAvatar />))
5042
cy.get("svg")
51-
cy.get("img:visible")
5243
})
5344
})

0 commit comments

Comments
 (0)