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

Commit 1dae053

Browse files
Merge pull request #66 from lmiller1990/lachlan/completed-testing
Get Cypress working
2 parents 3858718 + 8a3acaf commit 1dae053

Some content is hidden

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

55 files changed

+1246
-294
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ lerna-debug.log*
1616
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1717

1818
# Runtime data
19-
pids
19+
pids
2020
*.pid
2121
*.seed
2222
*.pid.lock

cypress.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"componentFolder": "packages/",
3+
"pluginsFile": "./packages/tests/plugins.js",
4+
"testFiles": "**/*.cy.*",
5+
"supportFile": "packages/tests/support.tsx",
6+
"ignoreTestFiles": "**/*.snap",
7+
"video": false,
8+
"fixturesFolder": false,
9+
"reporter": "spec"
10+
}

index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!--
2+
This file is required for Vite to run at the root of the project.
3+
It's very difficult to avoid this.
4+
One option is to move the playground/index.html up here instead.
5+
-->
6+
<!DOCTYPE html>
7+
<html lang="en">
8+
<head>
9+
<meta charset="utf-8" />
10+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
11+
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
12+
<title>Cypress's Test Playground</title>
13+
</head>
14+
<body></body>
15+
</html>

package.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
"build": "lerna run build --no-private --stream",
2222
"dev": "NODE_ENV=development vite serve playground --config ./vite.config.ts",
2323
"playground:build": "yarn install && yarn build && yarn bootstrap && NODE_ENV=production vite build playground --config ./vite.config.ts",
24-
"test": "cross-env NODE_ENV=test jest --config jest.config.js",
24+
"cy:open": "cypress open-ct",
25+
"cy:run": "cypress run-ct --quiet",
26+
"test:component": "cy:run",
27+
"test": "jest && yarn cy:run",
28+
"test:unit": "cross-env NODE_ENV=test jest --config jest.config.js",
2529
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix",
2630
"docs:dev:legacy": "vitepress dev docs",
2731
"docs:build:legacy": "vitepress build docs",
@@ -65,7 +69,8 @@
6569
"@vue/eslint-config-typescript": "^5.1.0",
6670
"@vuedx/typecheck": "^0.4.1",
6771
"@vuedx/typescript-plugin-vue": "^0.4.1",
68-
"@vueuse/motion": "^1.4.4",
72+
"@vueuse/motion": "1.5.4",
73+
"@vueuse/core": "4.9.1",
6974
"axe-core": "^4.1.2",
7075
"babel-jest": "^26.6.3",
7176
"change-case": "^4.1.1",
@@ -107,14 +112,21 @@
107112
"ts-jest": "^26.5.0",
108113
"ts-node": "^9.0.0",
109114
"typescript": "^4.1.3",
110-
"vite": "2.1.5",
115+
"vite": "2.2.4",
111116
"vite-plugin-components": "^0.8.3",
112117
"vite-plugin-pages": "^0.9.2",
113118
"vitepress": "^0.12.0",
114-
"vue": ">=3.0.5",
119+
"vue": "^3.0.11",
115120
"vue-jest": "^5.0.0-alpha.7",
116121
"vue-prism-editor": "^2.0.0-alpha.2",
117122
"vue-router": "^4.0.6",
118123
"vue3-perfect-scrollbar": "^1.5.5"
124+
},
125+
"devDependencies": {
126+
"@cypress/snapshot": "^2.1.7",
127+
"@cypress/vite-dev-server": "^1.2.6",
128+
"@cypress/vue": "^3.0.1",
129+
"@vue/test-utils": "^2.0.0-rc.6",
130+
"cypress": "^7.2.0"
119131
}
120132
}

packages/c-accordion/tests/__snapshots__/c-accordion.test.ts.snap

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import CAccordion from '../src'
2+
import { h } from 'vue'
3+
4+
it('should render properly', () => {
5+
cy.mount(<CAccordion></CAccordion>)
6+
})

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

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

packages/c-accordion/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.json",
33
"include": ["src"]
4-
}
4+
}

packages/c-alert/examples/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * as BaseAlert from './base-alert.vue'
2+
export * as WithAccent from './with-accent.vue'
3+
export * as WithIcon from './with-icon.vue'
4+
export * as WithStatus from './with-status.vue'
5+
export * as WithTitle from './with-title.vue'

packages/c-alert/tests/c-alert.cy.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as Examples from '../examples'
2+
import { h } from 'vue'
3+
import { CAlert, CAlertDescription, CAlertIcon, CAlertTitle } from '../src'
4+
5+
describe('Alert Examples', () => {
6+
Object.entries(Examples).map(([name, example]) => {
7+
it(`renders ${name} successfully`, () => {
8+
cy.mount(example.default).checkA11y()
9+
})
10+
})
11+
})
12+
13+
it('contains the correct role', () => {
14+
cy.mount(Examples.BaseAlert.default)
15+
.then(() => {})
16+
.get('[role=alert]')
17+
.should('exist')
18+
})
19+
20+
it.only('renders its children', () => {
21+
cy.mount(
22+
<CAlert data-testid="alert" variant="left-accent" status="info" mb="3">
23+
<CAlertIcon mr="2" />
24+
<CAlertTitle> Info alert </CAlertTitle>
25+
<CAlertDescription> Something just happened </CAlertDescription>
26+
</CAlert>
27+
)
28+
.get('[data-testid=alert]')
29+
.should('contain', 'Info alert')
30+
.and('contain', 'Something just happened')
31+
.and('descendants', 'svg')
32+
})

0 commit comments

Comments
 (0)