Skip to content

Commit 9a0ca2f

Browse files
author
Zerone
committed
test: add test
1 parent 6b03c9b commit 9a0ca2f

File tree

13 files changed

+1829
-4
lines changed

13 files changed

+1829
-4
lines changed

.github/workflows/test.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: 18
16+
- uses: pnpm/action-setup@v3
17+
with:
18+
version: 8
19+
- name: install
20+
run: pnpm i
21+
- name: test
22+
run: pnpm test

cypress.config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { defineConfig } from 'cypress';
22

33
export default defineConfig({
4+
includeShadowDom: true,
45
e2e: {
56
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}',
67
baseUrl: 'http://localhost:4173',
78
},
9+
10+
component: {
11+
devServer: {
12+
framework: 'vue',
13+
bundler: 'vite',
14+
},
15+
},
816
});

cypress/support/component-index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title>Components App</title>
8+
</head>
9+
<body>
10+
<div data-cy-root></div>
11+
</body>
12+
</html>

cypress/support/component.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// ***********************************************************
2+
// This example support/component.ts is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands';
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')
21+
22+
import { mount } from 'cypress/vue';
23+
24+
// Augment the Cypress namespace to include type definitions for
25+
// your custom command.
26+
// Alternatively, can be defined in cypress/support/component.d.ts
27+
// with a <reference path="./component" /> at the top of your spec.
28+
declare global {
29+
namespace Cypress {
30+
interface Chainable {
31+
mount: typeof mount;
32+
}
33+
}
34+
}
35+
36+
Cypress.Commands.add('mount', mount);
37+
38+
// Example use:
39+
// cy.mount(MyComponent)

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
"dev": "vite",
4545
"build": "run-p type-check \"build-js {@}\" --",
4646
"preview": "vite preview",
47-
"test:unit": "vitest",
48-
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
49-
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
47+
"test": "cypress run --component && vitest run",
48+
"test:snap": "vitest",
49+
"test:dev": "cypress open --component",
5050
"build-only": "vite build",
5151
"build-js": "node scripts/build.js",
5252
"type-check": "vue-tsc --build --force",

src/__tests__/__snapshots__/index.spec.tsx.snap

+477
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)