Skip to content

Commit

Permalink
refactor: cypress directory common and utils test method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-huxiyang committed Dec 10, 2024
1 parent b8bfcfa commit 75f4799
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 200 deletions.
15 changes: 0 additions & 15 deletions cypress/common/h5/pageWhiteTest.js

This file was deleted.

32 changes: 32 additions & 0 deletions cypress/e2e/common/pageWhiteTest.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { visitH5Demo, visitTaroDemo } from '../utils/visit-demo.js'
import data from '../../../src/config.json'

const { nav } = data
export const checkH5Blank = () => {
const componentArr = nav
.map((i) => i.packages)
.flat(Infinity)
.filter((i) => i.show)
.map((i) => i.name)

it('check h5 demos blank', () => {
componentArr.forEach((com) => {
visitH5Demo(com)
})
})
}
export const checkTaroBlank = () => {
it('check taro demos blank', () => {
nav.forEach((item) => {
const path = item.enName
item.packages
.filter((i) => i.show && i.taro && i.version === '3.0.0')
.forEach((i) => {
visitTaroDemo(path, i.name)
})
})
})
}
Cypress.on('uncaught:exception', (err, runnable) => {
return false
})
2 changes: 1 addition & 1 deletion cypress/e2e/h5/base.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { visitH5Demo } from '../common/visit-demo'
import { visitH5Demo } from '../utils/visit-demo'

describe('base components test', () => {
it('Button', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/h5/bussiness.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { visitH5Demo } from '../common/visit-demo'
import { visitH5Demo } from '../utils/visit-demo'

describe('bussiness components test', () => {
it('Barrage', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/h5/dentry.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { visitH5Demo } from '../common/visit-demo'
import { visitH5Demo } from '../utils/visit-demo'

describe('dentry components test', () => {
it('Address', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/h5/exhibition.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { visitH5Demo } from '../common/visit-demo'
import { visitH5Demo } from '../utils/visit-demo'

describe('exhibition components test', () => {
it('Animate', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/h5/feedback.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { visitH5Demo } from '../common/visit-demo'
import { visitH5Demo } from '../utils/visit-demo'

describe('feedback components test', () => {
it('ActionSheet', () => {
Expand Down
18 changes: 11 additions & 7 deletions cypress/e2e/h5/index.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import './base.cy'
import './layout.cy'
import './nav.cy'
import './dentry.cy'
import './bussiness.cy'
import './exhibition.cy'
import './feedback.cy'
import { checkH5Blank } from '../common/pageWhiteTest.cy'

// import './base.cy'
// import './layout.cy'
// import './nav.cy'
// import './dentry.cy'
// import './bussiness.cy'
// import './exhibition.cy'
// import './feedback.cy'

checkH5Blank() // 全部组件demo的白屏测试
2 changes: 1 addition & 1 deletion cypress/e2e/h5/layout.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { visitH5Demo } from '../common/visit-demo'
import { visitH5Demo } from '../utils/visit-demo'

describe('layout components test', () => {
it('Divider', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/h5/nav.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { visitH5Demo } from '../common/visit-demo'
import { visitH5Demo } from '../utils/visit-demo'

describe('nav components test', () => {
it('BackTop', () => {
Expand Down
20 changes: 0 additions & 20 deletions cypress/e2e/taro/base.cy.js

This file was deleted.

14 changes: 0 additions & 14 deletions cypress/e2e/taro/bussiness.cy.js

This file was deleted.

45 changes: 0 additions & 45 deletions cypress/e2e/taro/dentry.cy.js

This file was deleted.

22 changes: 0 additions & 22 deletions cypress/e2e/taro/exhibition.cy.js

This file was deleted.

22 changes: 0 additions & 22 deletions cypress/e2e/taro/feedback.cy.js

This file was deleted.

12 changes: 2 additions & 10 deletions cypress/e2e/taro/index.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
import './base.cy'
import './layout.cy'
import './nav.cy'
import './dentry.cy'
import './bussiness.cy'
import './exhibition.cy'
import './feedback.cy'
import { checkTaroBlank } from '../common/pageWhiteTest.cy'

Cypress.on('uncaught:exception', (err, runnable) => {
return false
})
checkTaroBlank() // 全部组件demo的白屏测试
17 changes: 0 additions & 17 deletions cypress/e2e/taro/layout.cy.js

This file was deleted.

16 changes: 0 additions & 16 deletions cypress/e2e/taro/nav.cy.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const visitH5Demo = (componentName, delay = 800) => {
export const visitH5Demo = (componentName, delay = 500) => {
const getPath = () => `${Cypress.env('baseUrl')}${componentName}`
cy.visit(getPath(componentName), {
onBeforeLoad: (win) => {
Expand All @@ -11,9 +11,9 @@ export const visitH5Demo = (componentName, delay = 800) => {
cy.get('#nav').contains(componentName)
cy.wait(delay)
}
export const visitTaroDemo = (componentName, delay = 1000) => {
export const visitTaroDemo = (path, componentName, delay = 1000) => {
const getPath = (component) =>
`${Cypress.env('baseUrl')}base/pages/${component.toLowerCase()}/index`
`${Cypress.env('baseUrl')}${path}/pages/${component.toLowerCase()}/index`

cy.visit(getPath(componentName))
cy.get('.applets-demo-header').contains(componentName)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
"test:ui": "vitest --ui --coverage",
"cypress:run": "cypress run --env baseUrl=http://localhost:5173/react/demo.html#/zh-CN/component/ 'cypress/e2e/h5/index.cy.js'",
"cypress:open": "cypress open --env baseUrl=http://localhost:5173/react/demo.html#/zh-CN/component/ 'cypress/e2e/h5/index.cy.js'",
"cypress:run:taro": "cypress run --env baseUrl=http://localhost:10086/#/ --spec 'cypress/e2e/taro/index.cy.js'",
"cypress:open:taro": "cypress open --env baseUrl=http://localhost:10086/#/ --spec 'cypress/e2e/taro/index.cy.js'",
"cypress:run:taro": "cypress run --env baseUrl=http://localhost:10086/#/ 'cypress/e2e/taro/index.cy.js'",
"cypress:open:taro": "cypress open --env baseUrl=http://localhost:10086/#/ 'cypress/e2e/taro/index.cy.js'",
"e2e:run:h5": "pnpm dev & pnpm cypress:run",
"e2e:open:h5": "pnpm dev & pnpm cypress:open",
"e2e:run:taro": "start-server-and-test dev:taro:h5 http://localhost:10086 cypress:run:taro",
Expand Down

0 comments on commit 75f4799

Please sign in to comment.