Skip to content

Commit a04a7c9

Browse files
committed
volar reproduction
1 parent 4b10ffd commit a04a7c9

File tree

8 files changed

+86
-5
lines changed

8 files changed

+86
-5
lines changed

cypress.config.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { defineConfig } from 'cypress'
1+
import { defineConfig } from "cypress";
22

33
export default defineConfig({
44
e2e: {
5-
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}',
6-
baseUrl: 'http://localhost:4173'
7-
}
8-
})
5+
specPattern: "cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}",
6+
baseUrl: "http://localhost:4173",
7+
},
8+
9+
component: {
10+
devServer: {
11+
framework: "vue",
12+
bundler: "vite",
13+
},
14+
},
15+
});

cypress.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { mount } from "cypress/vue";
2+
3+
declare global {
4+
namespace Cypress {
5+
interface Chainable {
6+
mount: typeof mount;
7+
}
8+
}
9+
}
Lines changed: 12 additions & 0 deletions
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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-disable @typescript-eslint/no-namespace */
2+
// ***********************************************************
3+
// This example support/component.ts is processed and
4+
// loaded automatically before your test files.
5+
//
6+
// This is a great place to put global configuration and
7+
// behavior that modifies Cypress.
8+
//
9+
// You can change the location of this file or turn off
10+
// automatically serving support files with the
11+
// 'supportFile' configuration option.
12+
//
13+
// You can read more here:
14+
// https://on.cypress.io/configuration
15+
// ***********************************************************
16+
17+
// Import commands.js using ES2015 syntax:
18+
import "./commands";
19+
20+
// Alternatively you can use CommonJS syntax:
21+
// require('./commands')
22+
23+
import { mount } from "cypress/vue";
24+
25+
Cypress.Commands.add("mount", mount);
26+
27+
// Example use:
28+
// cy.mount(MyComponent)

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"build": "run-p type-check build-only",
77
"preview": "vite preview --port 4173",
88
"test:unit": "vitest --environment jsdom",
9+
"test:component": "cypress open --component --browser=chrome",
10+
"test:component:ci": "cypress run --component --browser=chrome",
911
"test:e2e": "start-server-and-test preview http://127.0.0.1:4173/ 'cypress open --e2e'",
1012
"test:e2e:ci": "start-server-and-test preview http://127.0.0.1:4173/ 'cypress run --e2e'",
1113
"build-only": "vite build",

src/components/AppButton.cy.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import AppButton from "./AppButton.vue";
2+
3+
describe("AppButton.cy.ts", () => {
4+
it("renders an app button", () => {
5+
cy.mount(() => <AppButton></AppButton>);
6+
});
7+
});

tsconfig.cypress.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "./tsconfig.app.json",
3+
"include": ["**/*.cy.*"],
4+
"exclude": [],
5+
"files": ["./cypress.d.ts"],
6+
"compilerOptions": {
7+
"isolatedModules": false,
8+
"composite": true,
9+
"lib": ["DOM"],
10+
"jsx": "preserve",
11+
"types": ["cypress"],
12+
}
13+
}

tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
},
1313
{
1414
"path": "./tsconfig.vitest.json"
15+
},
16+
{
17+
"path": "./tsconfig.cypress.json"
1518
}
1619
]
1720
}

0 commit comments

Comments
 (0)